GetImageByURL and Media Library Alt tags

Alan Isaacson asked on May 11, 2017 17:33

I currently call images into my pages and use image links with the following code in a transformation

<a href="{% GetDocumentUrl() %}">{% GetImageByUrl(IllustrationImageFromMediaLibrary) %}</a> Does anyone know if it possible to call in an ALT tag that would be the title of the image in the media gallery? I use the code {% GetImageByUrl(IllustrationImageFromMediaLibrary) %} in a number of places and most would benefit from having an ALT tag. Any (helpful) suggestions allways appreciated.

Recent Answers


Trevor Fayas answered on May 11, 2017 19:28

As per the documentation, the GetImageByUrl accepts these parameters:

  • object imageUrl
  • object (int) maxSideSize
  • object (int) width
  • object (int) height
  • object alt

The only annoying thing is to get to the last one (alt) you have to put in the other parameters.

If you use the ASCX transformation you should be able to call the parameter by name: <%# GetImageByUrl(Eval("IllustrationImageFromMediaLibrary"), alt: "My Alt") %>

But if you want to use the K# syntax, you'll probably need to create a custom macro to get the image and set the alt tag manually.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.