Copied to clipboard

Flag this post as spam?

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


  • Mark W. Nielsen 13 posts 33 karma points
    Aug 11, 2011 @ 11:44
    Mark W. Nielsen
    0

    Use upload inside an <img> tag

    Hello my fellow Umbraco-holics.

    Its prolly just me who's turned blind+dump, but I just can't figure out the solution for my problem.

    I got a document type, it contains 2 upload datatypes with the following name and alias:

    Name: Frontpage About | Alias: frontpageAbout
    Name: Frontpage Download | Alias: frontpageDownload

    My problem is, that when i try to use it inside a macro i just can't get the path for the pictures inside my <img src="......PATH HERE.....">

    When i try to look at the source code the src part of the img tag is just empty. I would perfer not to show my XSLT code atm. because its really really messy. If its needed just give me a shout, then I'll post it.

     

    Regards,
    Mark W. Nielsen

     

  • Mark W. Nielsen 13 posts 33 karma points
    Aug 11, 2011 @ 11:49
    Mark W. Nielsen
    0

    Just updated my XSLT abit, so here it is:

     

    <?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:variable name="button_download" select="$currentPage/frontpageDownload" />
        <xsl:variable name="button_about" select="$currentPage/frontpageAbout" />

    <xsl:template match="/">

    <!-- start writing XSLT -->
    <xsl:choose>
      <xsl:when test="$currentPage/@nodeName = 'UK'">
        <div class="button_img" style="margin-right: 19px;">
          <href="download2.html">
            <img class="frontpage_button" src="$button_download" />
          </a>
        </div>
        <div class="button_img">
          <href="download2.html">
            <img class="frontpage_button" src="$button_about" />
          </a>
        </div>
      </xsl:when>
      <xsl:when test="$currentPage/@nodeName = 'DK'">
        <div class="button_img" style="margin-right: 19px;">
          <href="download2.html">
            <img class="frontpage_button" src="$button_download" />
          </a>
        </div>
        <div class="button_img">
          <href="download2.html">
            <img class="frontpage_button" src="$button_about" />
          </a>
        </div>
      </xsl:when>
      <xsl:otherwise>
        <div class="button_img" style="margin-right: 19px;">
          <href="download2.html">
            <img class="frontpage_button" src="$button_download" />
          </a>
        </div>
        <div class="button_img">
          <href="download2.html">
            <img class="frontpage_button" src="$button_about" />
          </a>
        </div>
      </xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    </xsl:stylesheet>

  • Laurence Gillian 597 posts 1214 karma points
    Aug 11, 2011 @ 11:49
    Laurence Gillian
    0

    Go on, show your code! I've written some truely cringe worthy stuff before ;)

    In the most basis level, you could try...

    <img src="{$currentPage/frontpageAbout}" alt="" />

    This should just get the value of frontpageAbout from your node in question. No fancy logic to check it exists or anything.

  • Laurence Gillian 597 posts 1214 karma points
    Aug 11, 2011 @ 11:52
    Laurence Gillian
    0

    You are just missing the curly bracket syntax Mark, check out this thread (and scroll to the bottom / Chriztian's solution) it's got it covered! /Lau

  • Mark W. Nielsen 13 posts 33 karma points
    Aug 11, 2011 @ 11:53
    Mark W. Nielsen
    0

    Laurence that was what i needed. Just tried like 100 other ways that was almost the "{$currentPage/frontpageAbout}" you just gave me. But it worked perfectly! And there are no need ot check if it exist. Cause it always will :)

    Thanks a billion!

  • Laurence Gillian 597 posts 1214 karma points
    Aug 11, 2011 @ 11:57
    Laurence Gillian
    0

    Out of interest what is your <xsl:choose> bit doing? Each part is the same?

    Also remember to bosh a alt="" on the image, even if its just alt="(null)", otherwise the screenreader reads the images URL out.

    (: Lau

  • Mark W. Nielsen 13 posts 33 karma points
    Aug 11, 2011 @ 12:05
    Mark W. Nielsen
    0

    The is checing what the node name is, and then change the depending on what the nodename are. I just didn't corrent the links when i posted the XSLT.

     

    And thanks for the memo on the alt=""

     

    You can see my entire XSLT here, as the finished "product" :P

     

    <xsl:choose>
      <xsl:when test="$currentPage/@nodeName = 'UK'">
        <div class="button_img" style="margin-right: 19px;">
          <href="/download.aspx">
            <img alt="" class="frontpage_button" src="{$currentPage/frontpageDownload}" />
          a>
        div>
        <div class="button_img">
          <href="/about-us.aspx">
            <img alt="" class="frontpage_button" src="{$currentPage/frontpageAbout}" />
          a>
        div>
      xsl:when>
      <xsl:when test="$currentPage/@nodeName = 'DK'">
        <div class="button_img" style="margin-right: 19px;">
          <href="/brochure.aspx">
            <img alt="" class="frontpage_button" src="{$currentPage/frontpageDownload}" />
          a>
        div>
        <div class="button_img">
          <href="/om-os.aspx">
            <img alt="" class="frontpage_button" src="{$currentPage/frontpageAbout}" />
          a>
        div>
      xsl:when>
      <xsl:otherwise>
        <div class="button_img" style="margin-right: 19px;">
          <href="/downloads.aspx">
            <img alt="" class="frontpage_button" src="{$currentPage/frontpageDownload}" />
          a>
        div>
        <div class="button_img">
          <href="/ueber-uns.aspx">
            <img alt="" class="frontpage_button" src="{$currentPage/frontpageAbout}" />
          a>
        div>
      xsl:otherwise>
    xsl:choose>

  • 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