Retrieve thumbnail URL from page properties in AEM 6.4 using sightly

Avatar

Avatar

irmantasluk

Avatar

irmantasluk

irmantasluk

28-08-2020

Is it possible to insert thumbnail image URL from page properties of Thumbnail tab into og:image inside meta tag. I am able to get values of pageTitle and description properties but not the image. Or is there a better way to handle this?

<meta property="og:url" content="${head.pagePath}" />
<meta property="og:title" content="${properties.pageTitle}" />
<meta property="og:description" content="${properties['jcr:description']}" />
<meta property="og:image" content="imageURL" />
image page properties sightly thumbnail

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

irmantasluk

Avatar

irmantasluk

irmantasluk

31-08-2020

Thank you all for your replies. I studied Social Sharing core component source code for a bit and ended up re-using getThumbnail() method to get page thumbnail reference and that worked out as expected.

Answers (4)

Answers (4)

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

1.0K

Correct Answer

831

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

1.0K

Correct Answer

831
Arun_Patidar
MVP

31-08-2020

Thumbnail are generated either from template(DAM or browsed image) or uploading direct on page. If you have thumbnail reference from DAM then you can see a property in page otherwise you need to read from local but you can't use that in og tags.

 

 

Avatar

Avatar

Singaiah_Chintalapudi

MVP

Avatar

Singaiah_Chintalapudi

MVP

Singaiah_Chintalapudi
MVP

30-08-2020

It depends on your customization (Static/Editable templates). If you're not customizing anything then it would store here:/content/yourpagepath/jcr:content/image. If you look at the property of fileReference then you'll the image ref path. You'll have to use Server Side script (JavaScript API) or use Java to read this and inject back to HTL/HTML.

Avatar

Avatar

Nikhil-Kumar

MVP

Avatar

Nikhil-Kumar

MVP

Nikhil-Kumar
MVP

28-08-2020

@irmantasluk 


Try reading it through node props.

 

Avatar

Avatar

Varun_Shakya

MVP

Avatar

Varun_Shakya

MVP

Varun_Shakya
MVP

28-08-2020

if the thumbnail image is coming from DAM ,then the page have "image" node in jcr:content of page and that image node will be having fileReference property which will have your image path of thumbnail. In this case you can make use of resource object and get the child node image and then get the property(fileReference).

 

If the thumbnail has been uploaded from file system in template. In that case it will not be easy to get.i would say take thumbnail from DAM.