Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Is there a way to achieve global alternative text for all images on a site?
I have created a new property under the Image media type, and i got this working for my blog posts only.
IPublishedContent mainImage = Umbraco.AssignedContentItem.GetPropertyValue<IPublishedContent>("articleImage");
string mainImageAltText = mainImage.GetPropertyValue<string>("umbracoAltText"); }
Is there a way I can achieve this for every image across my site? Like if i put my markup in the master or a controller? Sorry new to Umbraco/MVC here so any guidance would be much appreciated.
The good way of doing it - create a helper that returns image URL an alternative text or even full tag for you.
Then use this helper everywhere on the site.
Did you find a solution for this topic? Can you share with our community?
No luck on this yet. Would I put this helper within my master? How would I then write it to check all images per page? All I can find when searching the forums is if I were to select each property individually.
You could use a dictionary item and then make all logic fall back to that dictionary value...
So, if an 'alt' value exists (from a page field value maybe or simply Model.Name) then use it otherwise use the dictionary item.
But obviously Alex's method is also a workable solution.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted