Copied to clipboard

Flag this post as spam?

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


  • Bruno Olsen 75 posts 316 karma points
    Dec 04, 2014 @ 11:33
    Bruno Olsen
    0

    7.1.9: GetMedia returns empty string

    This is driving me crazy. I'm setting up a website with version 7.1.9, the first one. I have a page (id 1050) with an image (media picker).

    Normally it should be pretty easy to get the image via something like:

    <xsl:value-of select="umbraco.library:GetMedia(umbraco.library:GetXmlNodeById(1050)/baggrundsbillede, 'false')/umbracoFile" />
    

    Now, in this case it doesn't work. I've even tried uploading a new picture, nothing. I've seen that some have had a similar issue in earlier version, solved simply by saving the image again, but still nothing.

    When I try

    <xsl:value-of select="umbraco.library:GetXmlNodeById(1050)/baggrundsbillede" />
    

    I get the right id for the image (1070 with the first image, 1078 with the second image). When I try

    <xsl:copy-of select="umbraco.library:GetMedia(umbraco.library:GetXmlNodeById(1050)/baggrundsbillede,0)" />
    

    all I get is an empty string. I've even tried

    <xsl:copy-of select="umbraco.library:GetMedia(1078,0)" />
    

    but still no xml output. And in the Media section all looks normal.

    Please, help!

    /Bruno

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Dec 04, 2014 @ 11:37
    Dennis Aaen
    1

    Hi Bruno,

    It´s a known bug in Umbraco 7.1.9 take a look at this issue http://issues.umbraco.org/issue/U4-5925 and vote for it.

    /Dennis

  • Bruno Olsen 75 posts 316 karma points
    Dec 04, 2014 @ 11:43
    Bruno Olsen
    0

    Hi Dennis

    Ok, done. And there's no work-around until it's solved?

    /Bruno

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Dec 04, 2014 @ 11:47
    Dennis Aaen
    0

    Hi Bruno,

    I haven´t heard of any work-around, how to solve this, and sometimes the work-arounds, will be placed on the case in the issue tracker.

    But you could vote for it and make a comment on the issue, so the HQ is aware that there are other that experience the same with the GetMedia on Umbraco 7.1.9

    /Dennis

  • Bruno Olsen 75 posts 316 karma points
    Dec 04, 2014 @ 11:49
    Bruno Olsen
    0

    Hi Dennis

    Ok, thanks. Voted and commented

    /Bruno

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Dec 04, 2014 @ 12:32
    Jan Skovgaard
    0

    Hi Bruno

    There is no workaround if you want to use XSLT. Otherwise you could try to use Razor instead. As long as macroes are kept seperate you can easily use XSLT and Razor macroes in the same project. However it can be a bit confusing to keep track of the different technologies being used though.

    But using Razor might be the way forward if you need to get something finished and ready for deploy quickly since there is no official timestamp for a fixed version.

    In the documentation for the image cropper you can see some Razor examples showing how to fetch images as well http://our.umbraco.org/documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors-v7/Image-Cropper

    Hope this helps.

    /Jan

  • Bruno Olsen 75 posts 316 karma points
    Dec 04, 2014 @ 12:50
    Bruno Olsen
    0

    Hi Jan

    I'll try to have a look at Razor, although my previous experience with it tells me it will take me a million hours to make a simple script work :) Maybe I can get things working faster using .net c# :)

    /Bruno

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Dec 04, 2014 @ 14:11
    Jan Skovgaard
    0

    Hi Bruno

    Well I'm not a big Razor wizard and I prefer XSLT as well. But the Razor implementation has got a lot better in v7 than it was in earlier releases. 6 was fine too.

    And since Razor is a subset of c# I'm sure you'll figure it out pretty quickly :)

    /Jan

  • Bruno Olsen 75 posts 316 karma points
    Dec 05, 2014 @ 10:09
    Bruno Olsen
    0

    Ok, I threw something together that works as a temporary work-around. It's not pretty, but it'll do until a fix has been made.

    I made some .net implemented as a usercontrol, here's the codebehind:

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Net.Mail;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.Profile;
    using System.Xml;
    using System.Xml.XPath;
    using umbraco.BusinessLogic;
    using umbraco.cms.businesslogic.media;
    using umbraco.cms.businesslogic.member;
    using umbraco.cms.businesslogic.web;
    using Umbraco.Web;
    using System.Web.Security;
    using umbraco.presentation.nodeFactory;
    using System.Runtime.Remoting;
    using System.Web.Script.Serialization;
    
    
    namespace WebApplication2.Usercontrols
    {
        public partial class MediaGet : System.Web.UI.UserControl
        {
    
    
            protected void Page_Load(object sender, EventArgs e)
            {
                Page.Validate();
                if (Page.IsValid)
                {
                    int mediaId = Convert.ToInt32(Request.QueryString["id"]);
                    Media file = new Media(mediaId);
                    string url = file.getProperty("umbracoFile").Value.ToString();
    
                    Response.Write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                    Response.Write("<nodes>");
                    Response.Write("<url>");
                    Response.Write(url);
                    Response.Write("</url>");
                    Response.Write("</nodes>");
    
                }
             }
    
    
        }
    }
    

    I then just call the page /mediaget/

    Then I made an XSLT-makro, like this:

    <xsl:variable name="getimgurl">http://www.domain.dk/mediaget/?id=<xsl:value-of select="umbraco.library:GetXmlNodeById(1050)/baggrundsbillede" /></xsl:variable>
    
    <xsl:variable name="imgurl" select="umbraco.library:GetXmlDocumentByUrl($getimgurl)" />
    
    <xsl:copy-of select="$imgurl" />
    

    The copy-of is just to show me that it works :)

    Hope this can assist others while waiting for an actual fix :)

    /Bruno

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Dec 11, 2014 @ 08:31
    Dennis Aaen
    0

    Hi Bruno,

    There have been made a pull request now for fixing the issue with the GetMedia in XSLT.

    See this https://github.com/umbraco/Umbraco-CMS/pull/587 and http://issues.umbraco.org/issue/U4-5925

    /Dennis

     

  • Bruno Olsen 75 posts 316 karma points
    Dec 11, 2014 @ 09:43
    Bruno Olsen
    0

    Hi Dennis

    Thanks for the update :)

    /Bruno

Please Sign in or register to post replies

Write your reply to:

Draft