Forum Discussion
When doing an API call for messages with the label text "Events", I do see a field for teaser, but the value returned is one string:
"teaser" : "<P> <span class=\"lia-inline-image-display-wrapper lia-image-align-inline\" style=\"width: 480px;\"><img src=\"https://stage.liveopsnation.com/t5/image/serverpage/image-id/74iEAC9E1BB2EE4DFE6/image-size/large?v=1.0&px=999\" alt=\"youcandoit.png\" title=\"youcandoit.png\" /></span></P>\n<P>This is the article teaser.</P>"
Accessing the image is not straightforward as it would if there were keys for each element of the string. So how do I return just the URL for the image and, separately, just the actual text from the teaser? String gymnastics? What's the best way to do this? Anyone have a code example?
After API call you will get teaser node
"teaser" : "<P> <span class=\"lia-inline-image-display-wrapper lia-image-align-inline\" style=\"width: 480px;\"><img src=\"https://stage.liveopsnation.com/t5/image/serverpage/image-id/74iEAC9E1BB2EE4DFE6/image-size/large?v=..." alt=\"youcandoit.png\" title=\"youcandoit.png\" /></span></P>\n<P>This is the article teaser.</P>"
Assign this teaser value into a variable like this in your <#list></#list>
<#assign messageTeaser = message.teaser?split("<img","i") > <#assign messageTeaser?lower_case?contains("<img")> <#assign images = messageBody?split("<img","i") > <#assign getImageUrl = images[1]?split(" />","i") > <#assign getImage="<img class='img' "+getImageUrl[0]+" />" /> ${getImage}
Above code is to get first image from teaser.
If you want multiple images from teaser you can use
${images} in list
<#list images as image>
this will return all images from teaser under list
Related Content
- 9 months ago
- 2 years ago
- 10 months ago