Copied to clipboard

Flag this post as spam?

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


  • Mygel 9 posts 40 karma points
    Jun 24, 2014 @ 01:20
    Mygel
    0

    Image is being displayed as URL; not as Image

    Hey Forum, 

    I'm having this issue: The Image is being display as a URL rather than showing an image.
    http://imgur.com/xaqv4op

    In my views I have this:
    http://pastebin.com/Y78FZbgD

    My back Office looks like this:
    http://imgur.com/wtk8nkF

    The name of the alias is called 'test'.

    I tried using the Media Picker but I was getting the same results. No matter what I try I just can't get the URL into an image!I 'm also quite unsure how to get the pictures to be scaled to specific dimensions. If I could get some help that would be great. 

    -Mygel

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jun 24, 2014 @ 08:05
    Jeavon Leopold
    1

    Him you need to add the img tag, e,g.

    <div class="CourseImg">
        <img src="@article.test"/>
    </div>
    

    It looks like you are using Umbraco 6 so if you want to use a media picker instead see this documentation for a code snippet (Mvc, dynamic)

    Jeavon

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Jun 24, 2014 @ 08:09
    Dennis Aaen
    0

    Hi Mygel,

    You can do it in two ways one way is by using a Partial Views, or antother way is by uing Partial View Macro. The code snippet you have to right is the same, the difference is the way you added the file to your template.

    But if you want to get the image from the currentpage and you are using a media picker with alias of test, you could use the lines of code to get the image.

    @{      
        if (CurrentPage.HasValue("test")){                                        
            var dynamicMediaItem = Umbraco.Media(CurrentPage.test);
            <img src="@dynamicMediaItem.umbracoFile" alt="@dynamicMediaItem.Name" width="@dynamicMediaItem.umbracoWidth" height="umbracoHeight"/>
        }
    }

    But if you want to use the code you already have the only thing you´re missing this the image tag, since you get the path to the image, as I see it from the links you are provide in your post.

    So if you´re getting the image path by using is.

    @article.test

    The try this:

    <img src="@article.test" alt="@article.Name" />

    Hope this helps,

    /Dennis

     

     

Please Sign in or register to post replies

Write your reply to:

Draft