Copied to clipboard

Flag this post as spam?

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


  • Allan Gourlay 6 posts 26 karma points
    Nov 17, 2011 @ 12:12
    Allan Gourlay
    0

    version 4.7.1 GetMedia returns nothing

    Version 4.7.1

    IIS 7

    OS:Windows 7 Professionsl

    HI

    I've been sweating over this one for a day now and can't figure things out when trying to display an image from the Media Library.
    I've read many posts on this but nothing seems to work.

    The below just puts the actual zsl script in the text area
    <textarea width="250" rows="10">
        <xsl:value-of select="umbraco.library:GetMedia(1200,0)" />
    </textarea>

    The below does display the media ID OK
    <umbraco:Item field="testimage" runat="server" />

    The below just shows image not found
    <img src="{umbraco.library:GetMedia(1200, false)/Image/umbracoFile}"/> and the actual source view of the HTML rendered is the same.

    Any ideas what is going on.

    I've granted all the correct permisisons on the site folders and is a clean install with Simple Starter Kit installed.

    On another machine using an older version of Umbraco everything seems to work OK.

    Thanks

    Allan

     

  • Rich Green 2246 posts 4008 karma points
    Nov 17, 2011 @ 12:26
    Rich Green
    0

    Hey Allan,

    Welcome to the Umbraco forum!

    Im not sure why you're having a problem but might be worth trying this solution from here

    <xsl:variable name="mediaId" select="number($currentPage/testimage)" />

        <xsl:if test="$mediaId > 0">

            <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />

            <xsl:if test="$mediaNode/umbracoFile">

                <img src="{$mediaNode/umbracoFile}" height="{umbracoHeight}" width="{umbracoWidth}" />

            </xsl:if>

        </xsl:if>

    Let me know how it goes
    Rich

     

  • Rich Green 2246 posts 4008 karma points
    Nov 17, 2011 @ 12:27
  • Allan Gourlay 6 posts 26 karma points
    Nov 17, 2011 @ 13:52
    Allan Gourlay
    0

    No joy...

    Here's the actual template code.

    <%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>

    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
    <textarea width="250" rows="10">
        <xsl:value-of select="umbraco.library:GetMedia(1200,0)" />
    </textarea>
    hello
    <xsl:copy-of select="umbraco.library:GetMedia(1200, 'false')" />
    <img src="{umbraco.library:GetMedia(1200, false)/Image/umbracoFile}"/>
     <umbraco:Item field="testimage" runat="server" />
    <umbraco:Item runat="server" field="testimage" xslt="umbraco.library:GetMedia({0}, true())/@nodeName" />

    <xsl:variable name="mediaId" select="number($currentPage/testimage)" />
        <xsl:if test="$mediaId > 0">
            <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
            <xsl:if test="$mediaNode/umbracoFile">
                <img src="{$mediaNode/umbracoFile}" height="{umbracoHeight}" width="{umbracoWidth}" />
            </xsl:if>
        </xsl:if>

    </asp:Content>

     

    And the actual source of the rendered HTML which jsut shows the XSLT.Not sure where all the HTML headers and BODY is gone thoughI would think that the Master Page would include all that.  I think I might jsut start again with a clean install.

    <

    textareawidth="250"rows

    ="10">

    <xsl:value-ofselect="umbraco.library:GetMedia(1200,0)"/>

    </

    textarea

    >

    hello

    <

    xsl:copy-ofselect="umbraco.library:GetMedia(1200, 'false')"

    />

    <

    imgsrc

    ="{umbraco.library:GetMedia(1200, false)/Image/umbracoFile}"/>

    1200

    <

    xsl:variablename="mediaId"select="number($currentPage/testimage)"

    />

    <xsl:iftest="$mediaId > 0"><xsl:variablename="mediaNode"select="umbraco.library:GetMedia($mediaId, 0)"/><xsl:iftest="$mediaNode/umbracoFile"><imgsrc="{$mediaNode/umbracoFile}"height="{umbracoHeight}"width="{umbracoWidth}"/></xsl:if></xsl:if>

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Nov 17, 2011 @ 14:17
    Lee Kelleher
    0

    Hi Allan, welcome to Umbraco!

    Looks like you're trying to use XSLT directly within your template, afraid that's not going to work. To use XSLT, you would need to create a Macro for it first. (Take a look at this Umbraco.tv video about doing that).

    If you just want to display the image, then try using this code snippet:

    <umbraco:Item runat="server" Field="testimage" insertTextBefore="&lt;img src='" insertTextAfter="' alt='image' /&gt;" Xslt="umbraco.library:GetMedia({0}, 0)/umbracoFile" />

    The logic here is that we use the Item control/tag to get the value of "testimage", which if exists will output the escapes HTML <img> tag before and after it ... the Xslt attribute is used to make the call to GetMedia (from the cache/database).

    I know it might seem fairly complex - I'm sure you'll have questions, feel free to ask.

    Cheers, Lee.

  • Allan Gourlay 6 posts 26 karma points
    Nov 17, 2011 @ 14:41
    Allan Gourlay
    0

    Tried the adding the umbraco item in to a clean install and nothing showsnot even in the HTML source???

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Nov 17, 2011 @ 14:44
    Lee Kelleher
    0

    Hi Allan,

    When you say clean install, how do you mean? I'm assuming that you have a document-type with the media picker, etc?

    or could be an issue with the template? Would you might copy-n-pasting it here (again)?

    Cheers, Lee.

  • Allan Gourlay 6 posts 26 karma points
    Nov 17, 2011 @ 15:01
    Allan Gourlay
    0

    I installed Umbraco again to a new Database and IIS Website.

    I've set up a Media PIcker on the Document Type
    In the template I've added the code to render the image, which still doesn't work even when in the content of the page I've selected the image????

    Here's the template which does display the media ID but when trying to display the image nothing appears. All the fields have the full permissions but I'm think this version 4.7.1 is not working as I have used the exact same idea before in older versions with no problems.

    <%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>

    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">

    <br/>
    <umbraco:Item field="media" recursive="true" runat="server" />
    <br/>
    <umbraco:Item runat="server" Field="media" insertTextBefore="&lt;img src='" insertTextAfter="' alt='image' /&gt;" Xslt="umbraco.library:GetMedia({0}, 0)/umbracoFile" />
    </asp:Content>

  • Rich Green 2246 posts 4008 karma points
    Nov 17, 2011 @ 15:06
    Rich Green
    0

    Hi Allan,

    I believe you need to add recursive="true" to your 2nd line, like this:

    <umbraco:Item runat="server" Field="media" recursive="true" insertTextBefore="&lt;img src='" insertTextAfter="' alt='image' /&gt;" Xslt="umbraco.library:GetMedia({0}, 0)/umbracoFile" /> 

    Let us know how it goes!

    Rich

     

     

  • Allan Gourlay 6 posts 26 karma points
    Nov 17, 2011 @ 15:09
    Allan Gourlay
    0

    Still no joy:-(...not feeling the love for Umbraco at the moment

  • Rich Green 2246 posts 4008 karma points
    Nov 17, 2011 @ 15:16
    Rich Green
    1

    Hey Allan,

    Fear not, we'll definately get there.

    Believe me what you are trying to achieve works!

    There must be something we're missing so let's go from the start.

    1) Is it possible to post a picture / screenshot of your content tree

    2) Are you 100% sure you're using a Media Picker datatype for a property named 'media' 

    3) What Document Type is the 'media' property on

    Rich



  • Allan Gourlay 6 posts 26 karma points
    Nov 17, 2011 @ 15:26
    Allan Gourlay
    0

    Rich

    I'm happy to do a remote session if you want to give me your contact details.

  • Rich Green 2246 posts 4008 karma points
    Nov 17, 2011 @ 15:29
    Rich Green
    0

    No problem, Skype name sent

Please Sign in or register to post replies

Write your reply to:

Draft