Skip to content

How to work with the Media service

Our Media Service provides the images in the appropriate sizes. This article describes the pain and a modern solution for html clients: Responsive images

Thumbnail creation

We are using AI to resize and crop the pictures if the requested size is smaller than 1024 pixels. The service analyzes the image, identifies the region of interest (ROI), and generates smart cropping coordinates based on the ROI. If the requested image is larger than 4 MB or if the requested size is larger than 1024 pixels then a simple resizing and cropping algorithm is used.

Service is taking the identifier of an ImageObject in our Infocenter and processes its content image.

https://media-v2.discover.swiss/image/GDL_402736821?height=300&width=250
https://media-v2.discover.swiss/image/{identitifier}?width={w}&height={h}

Parameter Type Description
identifier string Identifier of the image-object
width int Width of the thumbnail, in pixels.
height int Height of the thumbnail, in pixels.
nobiblio bool if true - removes info text from image. If image is too small (less then 150 x 150) - text excluded by default

The image references in all Infocenter objects is extended by the basic thumbnail url:

{
    "dataGovernance": [
        ...
    ],
    "contentUrl": "http://img.oastatic.com/img/56338413/.jpg",
    "thumbnailUrl": "https://media-v2.discover.swiss/image/img_4kq_fgddiebd",
    "@id": "https://api.discover.swiss/info/v2/imageObjects/img_4kq_fgddiebd",
    "identifier": "img_4kq_fgddiebd"
}
This thumbnail URL should be used to retrieve the picture from the media service. Each of our environments and versions are using a different media service.

Image bibliography

Discover.swiss automatically adds bibliography to the picture served by the media service. The author and the source are presented in the picture, in case it is an unknown author, the provider name will be used. With the query parameter 'nobiblio=true' you can disable the automatic inclusion of the bibliography.

Bibliography might be one of the next: - Author given name + author family name + source name - Author given name + author family name (if source name is missing) - Provider name (if all above is missing)

Info

The image should be 300-250 px for the bibliography to be visible (height=300&width=250). The bibliography will be excluded if the image is too small. The decision will be done based on the ratio of the picture and therefore there is no clear rule when it automatically disappears.

Bibliography example: Bibliography sample

Tour map image

https://media-v2.discover.swiss/mapimage/{identifier}?width={w}&height={h}

Returns image with tour path

Parameter Description
identifier Identifier of the image-object
width Width of the thumbnail, in pixels.
height Height of the thumbnail, in pixels.

Features

  • If both width and height are missing or less than 0, the picture is returned in its original size.
  • If one of the parameter is bigger than the original, this parameter is set to original. The ratio is kept.
  • If only one is missing the ratio is kept.
  • If any exception occurs the picture is returned in its original size.
  • If the ImageObject or the in contentUrl referenced image doesn't exist "404 Not found" will be returned.

Sample app

You can check the feature in our sample app as well: demo.discover.swiss


Last update: October 7, 2021 14:58:42