Copied to clipboard

Flag this post as spam?

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


  • Kate 267 posts 610 karma points
    Oct 01, 2014 @ 19:55
    Kate
    0

    Alt-text on images

    <!-- /* Font Definitions */ @font-face {font-family:Times; panose-1:2 0 5 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:"MS 明朝"; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:128; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:fixed; mso-font-signature:1 134676480 16 0 131072 0;} @font-face {font-family:"MS 明朝"; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:128; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:fixed; mso-font-signature:1 134676480 16 0 131072 0;} @font-face {font-family:Cambria; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 0 0 0 1 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:Cambria; mso-ascii-font-family:Cambria; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"MS 明朝"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Cambria; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-ansi-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-family:Cambria; mso-ascii-font-family:Cambria; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"MS 明朝"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Cambria; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} @page WordSection1 {size:595.0pt 842.0pt; margin:3.0cm 2.0cm 3.0cm 2.0cm; mso-header-margin:35.4pt; mso-footer-margin:35.4pt; mso-paper-source:0;} div.WordSection1 {page:WordSection1;} -->

    Hi

     

    I have a problem with one of my old sites. (Umbraco version 4)
    I want to put a Alt-text on all my images, but I’m having a problem with this one.

     

    Here is the code I got so fare: (The problem is marked with XXX)

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">
    <div class="cntSlider cntSliderSmall">
    <div class="slideHolder">
    <div class="sliderText">
    <div class="header"><xsl:apply-templates select="$currentPage/ancestor-or-self::*[normalize-space(overskriftPTopBillede)][1]/overskriftPTopBillede" />&nbsp;</div>
    <div class="teaser"><xsl:apply-templates select="$currentPage/ancestor-or-self::*[normalize-space(tekstPTopBillede)][1]/tekstPTopBillede" />&nbsp;</div>
    </div>
    <div id="noSlideshow"> <!-- Hvis slideshowet skal køre skal id = slideshow -->
    <div class="active">
    <xsl:apply-templates select="$currentPage/ancestor-or-self::*[normalize-space(topBilledeSubPages)][1]/topBilledeSubPages" />
    &nbsp;
    </div>
    </div>
    </div>
    </div>
    </xsl:template>

    <xsl:template match="overskriftPTopBillede">
    <xsl:variable name="header" select="$currentPage/ancestor-or-self::*[normalize-space(overskriftPTopBillede)][1]/overskriftPTopBillede" />
    <xsl:value-of select="$header" />
    </xsl:template>

    <xsl:template match="tekstPTopBillede">
    <xsl:variable name="sliderText" select="$currentPage/ancestor-or-self::*[normalize-space(tekstPTopBillede)][1]/tekstPTopBillede" />
    <xsl:value-of select="umbraco.library:StripHtml($sliderText)" disable-output-escaping="yes" />
    </xsl:template>

    <xsl:template match="topBilledeSubPages">
    <xsl:variable name="media" select="umbraco.library:GetMedia(., false())" />
    <xsl:if test="$media">
    <xsl:variable name="url" select="$media/umbracoFile" />
    <xsl:variable name="width" select="$media/umbracoWidth" />
    <xsl:variable name="height" select="$media/umbracoHeight" />
    <xsl:variable name="alttext" select="XXX" />
    <img src="{$url}" width="{$width}" height="{$height}" alt="{$alttext}" />
    </xsl:if>
    </xsl:template>

    </xsl:stylesheet>

     

     

    Hope you can help.

    Thanx

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Oct 01, 2014 @ 19:57
    Dennis Aaen
    100

    Hi Kate,

    Okay if you have added the property to your page document type so you are add the altText on the page that you are viewing in the browers, then you should call it with $CurrentPage/propertyAlias.

    So in your case we make the variable like this:

    <xsl:variable name="alttext" select="$CurrentPage/altText" />

    Then you should get the alt text on your image.

    Hope this helps,

    /Dennis

  • Kate 267 posts 610 karma points
    Oct 01, 2014 @ 19:59
    Kate
    0

    Perfect, just what I need.

    Thanks for your help

Please Sign in or register to post replies

Write your reply to:

Draft