Copied to clipboard

Flag this post as spam?

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


  • Michelle Saldana 4 posts 74 karma points
    22 days ago
    Michelle Saldana
    0

    Adding Alt Text to all photos

    I need help getting my alt text to populate on the front-end.

    I added my alt text field to the Image Media Type. Where do I add the code string, so it populates on the front-end? I only have 3 templates: Master, Content and Home.

    Is this the correct code?

    alt="@(item.GetPropertyValue

    I am not a web developer, so please explain this like I'm 10yrs old. Let me know exactly where is goes, and if you have the correct code, that would be very helpful. This really is a feature that should be provided "out-of-the-box" for SEO purposes.

    Thank You. Michelle

    snapshot of media type

  • David Peck 634 posts 1665 karma points c-trib
    22 days ago
    David Peck
    0

    If item is the media item then :

    <img src="@item.Url" alt="@item.GetPropertyValue("umbracoAltText")" />
    

    should be all you need.

  • Michelle Saldana 4 posts 74 karma points
    22 days ago
    Michelle Saldana
    0

    Do you know what template I place that code in? Can I place it anywhere in the file? Thanks soo much for your help.

  • David Peck 634 posts 1665 karma points c-trib
    22 days ago
    David Peck
    0

    There is probably a file in the Views folder which has the same name as the type of page. You can add it there.

    See Dennis's solution here: https://our.umbraco.com/forum/developers/razor/62062-Display-an-image

  • Michelle Saldana 4 posts 74 karma points
    22 days ago
    Michelle Saldana
    0

    My page type is both "Page" and "News Article". Those are the pages that most utilize my images.

    In my partial view, I have my "Media" file. I'm assuming I put that snippet of code on that page. Do you think this is correct? Can I put it anywhere on the page? Sorry I'm soo clueless. I'm a front-end designer, forced to do back-end work.

    enter image description here

  • Nevin George 12 posts 82 karma points
    18 days ago
    Nevin George
    0

    Hi Michelle,

    Get the image property value using

    @{var image=Model.GetpropertyValue<IpublishedContent>("propertyAlias");var altText=image.GetpropertyValue<string>("umbracoAltText");}
    

    If you are in macro use model.content instead of Model

  • Michelle Saldana 4 posts 74 karma points
    15 days ago
    Michelle Saldana
    0

    We figured out what file to place the altText code. It's working now!! Thanks everyone.

Please Sign in or register to post replies

Write your reply to:

Draft