Copied to clipboard

Flag this post as spam?

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


  • Thomas Lee 38 posts 79 karma points
    May 26, 2015 @ 10:12
    Thomas Lee
    0

    Get image URL within media custom folder

    Hi Guys,

    I am trying to get a logo form media library, media->logos(folder)->logoA.png

    But i was return with 

    Cannot resolve a Url for a media item when there is no 'umbracoFile' property defined.

     

    This is my code, 

    var image = Umbraco.Media(CurrentPage.logo);
    <img src="/[email protected]&width=200&height=200&quality=90"/>

    If the image is not stored in the logos folder, it works fine. 

    Is there any kind souls around that can help me out?

    Thanks in advance!

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    May 26, 2015 @ 13:41
    Dennis Aaen
    0

    Hi Thomas,

    You could try to use the code below and see if it goes better.

    @{      
        if (CurrentPage.HasValue("logo")){                                         
            var image = Umbraco.Media(CurrentPage.logo);
            <img src="/[email protected]&width=200&height=200&quality=90"/> 
        }
    }
    

    I have also added a check to ensure that the image is only printed when there is assigned an item to the picker for the current page that you are visited in the browser. On this way you donĀ“t get any empty src on your image tags.

    Hope this helps,

    /Dennis

  • Thomas Lee 38 posts 79 karma points
    May 26, 2015 @ 14:04
    Thomas Lee
    0

    Hi Dennis,

    Thanks for replying!

    I just tried your method but the same error exist.

    its triggered by " var imageURL = @image.url; "

    I am still confuse, do you know if it's possible for me to store images in a logo folder using Umbraco?

    Thanks for helping!

    Thomas

Please Sign in or register to post replies

Write your reply to:

Draft