On the current website I am working on, I have added an alt text field to the image media type. I want to be able to pull that alt text value for all the images alt tags. I have a news macro set up as such:
I am not sure what the best way to access the newsThumbnail media picker's altText property is. @n.newsThumbnail.altText does not work. When I check what @n.newsThumbnail returns, it returns the url. I thought to get that I had to do @n.newsThumbnail.umbracoFile? I have had success manually pulling the values via this:
@{var media = Model.MediaById(1195);}
@media.altText
If I could figure out how to get the MediaById to pull the newsThumbnail ID's that would work perfect. unfortunately passing it n.newsThumbnail only gives it urls resulting in nothing being found. Not sure how to get the ID of the n.newsThumbnail to pass to that.
If n.newsThumbnail is returning the URL, it sounds like you might be using an Upload field rather than a Media Picker - can you confirm? An upload field has nothing to do with media items, so there will be no additional properties available. You could either add another property to your content node for the alt text, or switch over to using a media picker.
It orginally was an upload field, but I can definitely confirm it is media picker now. Here is a picture of the property in question. Thanks for the quick response. I might try deleting the property and remaking it.
Hmm, strange that it still returns the URL - after you changed it, did you re-pick the media and publish the page? If not, it might still have the old upload field value stored.
Thank you SO much for reminding I originally had the upload field as a media picker field! I made a new media picker property and now it returns the node Id and I have it correctly working. I guess changing from upload to media picker doesn't take effect well or something. Either way thank you though!
Yep - actually, changing the field on the document type for any type of field has no effect on your data/content until you republish it. Until then it will still have its original values.
Pull alt text from media picker type
On the current website I am working on, I have added an alt text field to the image media type. I want to be able to pull that alt text value for all the images alt tags. I have a news macro set up as such:
@media.altText
Hi Aaron,
If n.newsThumbnail is returning the URL, it sounds like you might be using an Upload field rather than a Media Picker - can you confirm? An upload field has nothing to do with media items, so there will be no additional properties available. You could either add another property to your content node for the alt text, or switch over to using a media picker.
Hope this helps,
Tom
It orginally was an upload field, but I can definitely confirm it is media picker now. Here is a picture of the property in question. Thanks for the quick response. I might try deleting the property and remaking it.
Hmm, strange that it still returns the URL - after you changed it, did you re-pick the media and publish the page? If not, it might still have the old upload field value stored.
Thank you SO much for reminding I originally had the upload field as a media picker field! I made a new media picker property and now it returns the node Id and I have it correctly working. I guess changing from upload to media picker doesn't take effect well or something. Either way thank you though!
Yep - actually, changing the field on the document type for any type of field has no effect on your data/content until you republish it. Until then it will still have its original values.
Glad you got it!
is working on a reply...