Copied to clipboard

Flag this post as spam?

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


  • Greg Berlin 818 posts 634 karma points
    Sep 12, 2012 @ 02:34
    Greg Berlin
    0

    Insert Media Library Image into Template in 4.9

    I'm really struggling with this... here's what i've tried:

    <textarea><umbraco:Item ID="Item2" field="featureImage" xslt="umbraco.library:GetMedia({0},false)" recursive="true" runat="server"/></textarea>

                    <umbraco:Item ID="Item1" field="featureImage" xslt="umbraco.library:GetMedia({0},false)/umbracoFile" insertTextBefore="&lt;img src=&quot;" insertTextAfter="&quot; class=&quot;alignleft&quot; /&gt;" recursive="true" runat="server"/>

                    <umbraco:Item ID="Item3" field="featureImage" xslt="umbraco.library:GetMedia({0},0)/umbracoFile" insertTextBefore="&lt;img src=&quot;" insertTextAfter="&quot; alt=&quot;vendor-logo&quot;/&gt;" runat="server"/></a>

     

    They all just render nothing (except the textarea, which renders an empty text area).  This is driving me crazy, can anybody help?

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 12, 2012 @ 06:32
    Fuji Kusaka
    0

    Hi Greg,

    Can you please try changing this

     <umbraco:ItemID="Item3"field="featureImage"xslt="umbraco.library:GetMedia({0},0)/umbracoFile"insertTextBefore="&lt;img src=&quot;"insertTextAfter="&quot; alt=&quot;vendor-logo&quot;/&gt;"runat="server"/>

    to

     <umbraco:ItemID="Item3"field="featureImage"xslt="umbraco.library:GetMedia({0},true)/umbracoFile"runat="server"/>

    //fuji

  • Greg Berlin 818 posts 634 karma points
    Sep 12, 2012 @ 07:35
    Greg Berlin
    0

    Thanks Fuji, but still no go - renders nothing. :(

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 12, 2012 @ 08:04
    Fuji Kusaka
    0

    Out of curiousity do you actually get the <img> tag at least ?

  • Greg Berlin 818 posts 634 karma points
    Sep 12, 2012 @ 08:07
    Greg Berlin
    0

    Nope, nothing at all renders

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 12, 2012 @ 08:14
    Fuji Kusaka
    0

    I just installed v4.9 but didnt have a go yet, looks to me that you are not even rendering the <img> tag. Have you tried the other way round?

    <img src='<umbraco:Item field="featureImage" runat="server" xslt="umbraco.library:GetMedia({0}, true)/umbracoFile" />'>
  • Greg Berlin 818 posts 634 karma points
    Sep 12, 2012 @ 17:14
    Greg Berlin
    0

    That just renders out an empty img tag, as expected.

    Pretty sure its the GetMedia() function that isn't working.  Has anybody been able to make this work on 4.9?

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 12, 2012 @ 20:23
    Fuji Kusaka
    0

    Greg since your are adding this value in the Template you should at least be getting something. Have you try adding this field by simply using the "Insert Umbraco Page Field" ?

    You should be getting an Id at least.

  • Greg Berlin 818 posts 634 karma points
    Sep 12, 2012 @ 20:35
    Greg Berlin
    0

    Yes, I get the media ID if i insert the item without the xslt.. which is why i think the Getmedia() function is broken...

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 12, 2012 @ 21:00
    Fuji Kusaka
    0

    Not sure but try this again .featureImage

    <img src='<umbraco:Item field="featureImage" runat="server" Xslt="umbraco.library:GetMedia({0},false())/umbracoFile"/>'/>
  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 12, 2012 @ 21:03
    Fuji Kusaka
    0

    If not have a look at Lee Kellecher Blogs, it might help.


    //fuji


  • Greg Berlin 818 posts 634 karma points
    Sep 12, 2012 @ 21:14
    Greg Berlin
    0

    Nah nothing using .featureImage either.  ugh!

    That blog post isn't a whole lot of use to me really... i'll try to make a macro to render the image later one - i'm concentrating on finishing the site, hoping somebody will have a workaround for this by the time i really need it :)

  • Robert Drayton 14 posts 34 karma points
    Sep 14, 2012 @ 13:18
    Robert Drayton
    0

    I've got exactly the same problem. Help!

    I get this with ?umbDebugShowTrace=true

    headerImage is the name of the image field.

     

    Error rendering Item 8 (NodeId '' : headerImage).
    Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "Umbraco.Web.umbraco.templateControls.Resources.resources" was correctly embedded or linked into assembly "umbraco" at compile time, or that all the satellite assemblies required are loadable and fully signed.
      at System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName)
      at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
      at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
      at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
      at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
      at umbraco.presentation.templateControls.ItemRenderer.XsltTransform(String xpath, String itemData, Boolean disableEscaping)
      at umbraco.presentation.templateControls.ItemRenderer.Render(Item item, HtmlTextWriter writer)

  • Robert Drayton 14 posts 34 karma points
    Sep 14, 2012 @ 13:33
    Robert Drayton
    0

    Greg, is your problem on a new install or an Upgrade?

    Mine is an upgrade and I'm wondering if that's something to do with it.

  • Robert Drayton 14 posts 34 karma points
    Sep 14, 2012 @ 14:19
    Robert Drayton
    0

    ok as a test I changed the name of getmedia to getmediax to see what error I would get and it's the same error, so I can only assume that it's as if the function doesn't exist any more.

  • Robert Drayton 14 posts 34 karma points
    Sep 14, 2012 @ 15:03
    Robert Drayton
    0

    ok it must be some kind of referencing thing.  It works fine from a macro but no longer directly in a template.  

    I've made a macro, bit more hassle but gets me over the issue: 

    <xsl:if test="string($currentPage/headerImage) != '' ">
    <xsl:element name="img">
    <xsl:attribute name="src">
    <xsl:value-of select="umbraco.library:GetMedia($currentPage/headerImage, 'false')/umbracoFile" />
    </xsl:attribute>
    </xsl:element>
    </xsl:if>

  • Greg Berlin 818 posts 634 karma points
    Sep 18, 2012 @ 02:26
    Greg Berlin
    0

    I made a Razor macro to get around this.. here it is if anybody is interested:

    @inherits umbraco.MacroEngines.DynamicNodeContext

     

    @{              

        var mediaId = @Parameter.MediaNode;

        var mediaUrl = @Model.MediaById(mediaId).umbracoFile; // @Model.Media(mediaId, "umbracoFile");

        var altText = @Parameter.AltText;

        var alignment = @Parameter.Alignment;

     

        if (!String.IsNullOrEmpty(mediaUrl))

        {

    <imgsrc='@mediaUrl'alt="@altText"align="@alignment"/>

        }

    }

     

Please Sign in or register to post replies

Write your reply to:

Draft