Copied to clipboard

Flag this post as spam?

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


  • Bas Schouten 135 posts 233 karma points
    Mar 31, 2010 @ 15:05
    Bas Schouten
    0

    Alt tag in XSLT

    I want to use the image Name as Alt tag. Does someone know if that is possible?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 31, 2010 @ 15:10
    Jan Skovgaard
    0

    Hi bas

    Yes that is possible. I think that you could actually just do it just by writing alt="{@nodeName}".

    Hope this helps.

    /Jan

  • Bas Schouten 135 posts 233 karma points
    Mar 31, 2010 @ 15:15
    Bas Schouten
    0

    Hi Jan,

    It helped a bit :-).

    Is shoud be alt="{umbraco.library:GetMedia($currentPage/data [@alias = 'Afbeelding'], false)/@nodeName}"

    Thanx!

    Bas

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Mar 31, 2010 @ 15:24
    Douglas Robar
    1

    For better performance (because GetMedia() is comparatively slow (especially if you use anything other than 0 or false() as the second parameter) I would encourage you to save the Afbeelding item in a variable and then reference it for all its properties.

    Something like:

    <xsl:variable name="image" select="umbraco.library:GetMedia($currentPage/data[@alias='Afbeelding'], false())" />
    <img src="{$image/data[@alias='umbracoFile']}" alt="{$image/@nodeName}" />

    You could also pick up the image width and heigh with the umbracoWidth and umbracoHeight properties. And all with one GetMedia() call.

     

    Every little bit helps!

     

    cheers,
    doug.

  • Bas Schouten 135 posts 233 karma points
    Mar 31, 2010 @ 16:49
    Bas Schouten
    0

    Hi Doug,

    Thanx for the reply, very userfull!

    cheers,

    Bas

     

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Mar 31, 2010 @ 18:12
    Douglas Robar
    0

    Be sure to mark the solution if it works for you. That will help the next person with a similar question.

    cheers,
    doug.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 31, 2010 @ 18:23
    Jan Skovgaard
    0

    +1 one for Doug's code snippet - I was in a bit of a hurry when I answered - but Doug's solution is indeed better.

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft