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 5 posts 75 karma points
    Mar 31, 2021 @ 18:27
    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 687 posts 1863 karma points c-trib
    Mar 31, 2021 @ 20:42
    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 5 posts 75 karma points
    Mar 31, 2021 @ 20:51
    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 687 posts 1863 karma points c-trib
    Mar 31, 2021 @ 21:06
    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 5 posts 75 karma points
    Mar 31, 2021 @ 22:48
    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
    Apr 04, 2021 @ 08:09
    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 5 posts 75 karma points
    Apr 07, 2021 @ 15:55
    Michelle Saldana
    0

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

  • Prabhat Shahi 1 post 21 karma points
    Dec 23, 2021 @ 15:31
    Prabhat Shahi
    0

    Hi Michelle,

    Could you tell me where you place the alt-text code and which code you place? Actually, I'm also not a developer like you. Thanks.

Please Sign in or register to post replies

Write your reply to:

Draft