Copied to clipboard

Flag this post as spam?

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


  • Chris 32 posts 108 karma points
    Dec 30, 2014 @ 16:16
    Chris
    0

    Get URL from image cropper in XSLT file

    Hi,

     

    I have create an XSLT file and associated macro to display a list of staff. However I can't seem to get the image URL from the image cropper property. It needs to go into here in my xslt file

    <figure style="background-image:url({current()/staffPicture})"></figure>

    I get this currently in the html

    <figure style="background-image:url({
      &quot;focalPoint&quot;: {
        &quot;left&quot;: 0.5,
        &quot;top&quot;: 0.5
      },
      &quot;src&quot;: &quot;/media/1009/mystaffmember.jpg&quot;
    })"></figure>

    Thanks.

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Dec 30, 2014 @ 16:42
    Dennis Aaen
    1

    Hi Chris and welcome to our.

    Have you seen the documentation for the Image Cropper. If not take a look here http://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/Built-in-Property-Editors/Image-Cropper, as you can see there is also an example how to use it with XSLT.

    Hope this helps,

    /Dennis

  • Chris 32 posts 108 karma points
    Dec 31, 2014 @ 09:01
    Chris
    0

    Hi Dennis,

    Thanks for the pointer. Unfortunatley I am still struggling.

    When I look at the image in the content section it has the url '/media/1009/mystaffmember.jpg'

    In my XSLT file if I use umbraco.library:GetMedia(@id, 0) I get the error 'No media is maching '1090'' (Bit of a typo there!)

    Obviously the @id is of the content and not the image. How do I get the image URL? The current()/staffPicture brings it back but with a lot of other info. I need something like current()/staffPicture.src or simailar

    Thanks,

    Chris

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

    Hi Chris

    What version of Umbraco are you using?

    If you follow the image url does the image then in fact load in your browser? If not there must be something wrong and it would be a good idea to try and re-upload the image. If it does then it might be an issue with the implementation of the xslt extension (bug perhaps).

    And may I ask why you want to attach the image as a background image rather than using an image tag for the rendering?

    Looking forward to hearing from you.

    /Jan

  • Chris 32 posts 108 karma points
    Dec 31, 2014 @ 11:46
    Chris
    0

    Hi Jan,

    I am using 7.2.

    Yes the url displays the image - http://dev.dartvaledentalcare.co.uk/media/1009/juliette-moor.jpg. It is part of the template at http://dev.dartvaledentalcare.co.uk/dentist and the background image style is used there.

    I am also having issues playing with the XSLT file. If I get it wrong I get a large red warning that takes up the whole screen and I have to go back to the umbraco root in the url as none of the menu items gets rid of it, this makes experimenting with the XSLT file *really* painful :-(

    Thanks,

    Chris

     

     

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

    Hi Chris,

    Okay since you are using Umbraco 7.2 I would recommned you to look at the Razor and try learn Razor. As you can see the Image Cropper in Umbraco 7.2 outputs JSON, http://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/Built-in-Property-Editors-v7/Image-Cropper

    So I think that you should try using Razor instead.If you are new to Umbraco I would also recommend you to have a look on the Umbraco TV some of the videos are free to watch, and some requires that you subscribe to Umbraco TV see plan and prices here: http://umbraco.tv/plans-signup/

    And some of the free videos can you find here: http://umbraco.tv/videos/umbraco-v7/ Other good starting points with Umbraco are http://our.umbraco.org/documentation/Using-Umbraco/Creating-Basic-Site/ and http://24days.in/umbraco/2014/how-to-set-up-an-umbraco-site/

    Hope this helps,

    /Dennis

     

     

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

    Hi Chris

    Well as Dennis suggest it's worth going with Razor on this one since there is a known bug with the GetMedia extesion in 7.2 - But seems that it should be fixed in the 7.2.1 release though pr. this issue http://issues.umbraco.org/issue/U4-5925

    /Jan

  • Chris 32 posts 108 karma points
    Dec 31, 2014 @ 12:24
    Chris
    0

    Many thanks. Managed to sort switching to MVC instead of using macros. Here is the code for anyone else that might come across this in the future. This is in my parent template file with child templates underneath of the same document type.

    @foreach (var page in CurrentPage.Children.Where("Visible").OrderBy("CreateDate desc"))
    { 
        if (page.staffType == "Dentist")
        {
            <div class="row">
                <div class="top30 service_photo col-sm-4 col-md-4 wow " style="visibility: visible; margin-top:20px;">
                    <figure style="background-image:url(@page.staffPicture.src)"></figure>
                </div>
                <div class="service_details col-sm-8 col-md-8 wow animated slideInRight animated" style="visibility: visible;">
                    <h2 class="section_header elegant">@page.staffName<small>@page.staffRegistrationNumber</small></h2>
                    <p>@page.staffDescription</p>
                </div>
            </div>
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft