Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Aaron 6 posts 26 karma points
    Jun 18, 2013 @ 17:34
    Aaron
    0

    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:

    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.
    Really appreciate any help, thanks!

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 18, 2013 @ 17:41
    Tom Fulton
    0

    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 

  • Aaron 6 posts 26 karma points
    Jun 18, 2013 @ 17:47
    Aaron
    0

    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.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 18, 2013 @ 17:50
    Tom Fulton
    0

    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.

  • Aaron 6 posts 26 karma points
    Jun 18, 2013 @ 17:57
    Aaron
    0

    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! 

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 18, 2013 @ 17:58
    Tom Fulton
    0

    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!

Please Sign in or register to post replies

Write your reply to:

Draft