Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

How to get images linked to an article while getting metadata.

digitalr3317510
Level 2
Level 2

Can you please advise us on the following query regarding the images linked to an article? 

We can get meta data for an article by using getMetadata(). Is there a way to get the images(image urls) for article image, social sharing image linked to the article?

Thanks.

5 Replies
Neil_Enns_-_Ado
Employee
Employee

Hi,

You asked this same question in the Digital Publishing Suite forum where it was answered: How to get images linked in an article while getting metadata?. Are you asking the question for DPS 2015 content?

Neil

digitalr3317510
Level 2
Level 2

Hi Neil,

Yes by mistake I had added that question in Digital Publishing Suite forum. But I need to know the way to retrieve the images for DPS 2015 content.

Thanks.

mikecyang
Employee
Employee

Hi,

The socialSharing image URL is part of the entity metadata, in the field "socialShareUrl":

// sample code

$objArticleEntity = new Article($arrCredentials, $arrParameters, $arrEndpoints);

$arrArticleMetadata = $objArticleEntity->getMetadata()->getResponse();

$strSocialSharingUrl = $arrArticleMetadata['socialSharingUrl'];

The thumbnail image URL can be generated by using the following:

https://pecs.publish.adobe.io/publication/{{publication-id}}/{{entity-type}}/{{entity-name}}/content...

// sample code for generating the article thumbnail URL

$strClientId = ""; // this is from the API key request form

// get the access token

$objArticleEntity = new Article($arrCredentials, $arrParameters, $arrEndpoints);

$arrUserData = $objArticleEntity->getToken()->getResponse();

$strAccessToken = $arrUserData['access_token'];

// get the entity content URL

$arrArticleMetadata = $objArticleEntity->getMetadata()->getResponse();

$strArticleContentUrl = $arrArticleMetadata['_links']['contentUrl']['href'];

// generates the thumbnail URL

$strThumbnailUrl = 'https://pecs.publish.adobe.io' + $strArticleContentUrl + "?api_key=" + $strClientId + "&user_token=" + $strAccessToken;

Please note that the thumbnail URL is only valid for 48 hours: the thumbnail URL requires the access token and the access token is valid for 48 hours.

Just in case: the $arrCredentials, $arrParameters, $arrEndpoints are variables generated by the PHP API examples.

- Mike

Neil_Enns_-_Ado
Employee
Employee

Note that Mike's response is for a server-side solution. There is no API to get this information from within article content in the viewer.

Neil