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
I have added a property (seoTitle) to my image data type, so that I can add seo titles to images I upload.
Now I would like to display this title but I cant get it to work.
@{ var mediaGet1 = Model.Content.GetPropertyValue<IPublishedContent>("aboutUsPicture"); var seoTitle = Model.Content.GetPropertyValue<IPublishedContent>("seoTitle"); if (mediaGet1 != null) { <img src="@mediaGet1.Url" alt="@seoTitle"/> } }
I thought it would be straight forward but this only displays the image, but not the alt title...
Any suggestions?
Cheers!
Hi Bent,
I think the problem is you are getting the seo title from the content item instead of the image. Can you try this :
@{ var mediaGet1 = Model.Content.GetPropertyValue<IPublishedContent>("aboutUsPicture"); var seoTitle = mediaGet1.GetPropertyValue<string>("seoTitle"); if (mediaGet1 != null) { <img src="@mediaGet1.Url" alt="@seoTitle"/> } }
Dave
did you solved your issue using the answer of @Dave? Could you share it with the community?
Have a nice day!
/Michaël
It absolutely worked and makes perfect sence!... Just had the weekend off ;)
Cheers Dave, thank you!...
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Alt title to image media type
I have added a property (seoTitle) to my image data type, so that I can add seo titles to images I upload.
Now I would like to display this title but I cant get it to work.
I thought it would be straight forward but this only displays the image, but not the alt title...
Any suggestions?
Cheers!
Hi Bent,
I think the problem is you are getting the seo title from the content item instead of the image. Can you try this :
Dave
Hi Bent,
did you solved your issue using the answer of @Dave? Could you share it with the community?
Have a nice day!
/Michaël
It absolutely worked and makes perfect sence!... Just had the weekend off ;)
Cheers Dave, thank you!...
is working on a reply...