Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

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

Avatar

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

Avatar

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

Avatar

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.

Avatar

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

Avatar

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

Avatar

Level 2

Thanks Mike and Neil for the above.