Copied to clipboard

Flag this post as spam?

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


  • Dibs 202 posts 991 karma points
    Apr 01, 2016 @ 15:06
    Dibs
    0

    Img tag alt property empty

    Dear Umbraco team

    I have a news document type with an image field & text field for alternative text. Both render as expected from a template using the following <img src="@Umbraco.TypedMedia(node.GetPropertyValue("newsImage")).Url" alt="@Umbraco.Field("newsImageAlternativeText")"/>

    I have created a partial view to return a list to include only news document types. This partial view is used on my home page template to render the news items including the image and alternative text field using the same code <img src="@Umbraco.TypedMedia(node.GetPropertyValue("newsImage")).Url" alt="@Umbraco.Field("newsImageAlternativeText")"/>

    Image render as expected but alt tag is empty, <img src="/media/1014/newsimage.jpg" alt="">

    Am i missing something or doing something wrong?

    Thanks Dibs

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Apr 01, 2016 @ 15:53
    Alex Skrypnyk
    100

    Hi Dibs,

    Umbraco.Field - returns value from current page.

    You have to get alternative text from child node like:

    src="@Umbraco.TypedMedia(node.GetPropertyValue("newsImage")).Url" alt="@node.GetPropertyValue("newsImageAlternativeText")"/>
    

    Thanks

  • Dibs 202 posts 991 karma points
    Apr 04, 2016 @ 08:20
    Dibs
    0

    Cheers Alex

    works a treat, thanks for explaining : )

    Dibs

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies