Copied to clipboard

Flag this post as spam?

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


  • Dan 1288 posts 3921 karma points c-trib
    Jun 18, 2013 @ 11:55
    Dan
    1

    CropUp behaviour

    Hi,

    I've installed CropUp into a 6.1.1 site.  I've created a CropUp data-type using 'umbracoFile' as the file property alias.  I've then added this data-type to the default umbraco image media type.

    I have created a bunch of crop configurations in the 'config > Eksponent.CropUp.config' file like so:

    <?xml version="1.0"?>
    <cropUp referenceWidth="620" referenceHeight="480" autoDetect="true" detectFaces="true" iis6="false" boxFaces="true" faceMargin="150" cacheCropData="false">
        <croppings>
            <add alias="homepageCarousel" name="Homepage carousel" width="936" height="390" />
            <add alias="generalBanner" name="General banner" width="696" height="390" />
            <add alias="latestNewsEvents" name="Latest news and events" width="156" height="104" />
            <add alias="feature" name="Feature" width="456" height="304" />
            <add alias="sideBlockStandard" name="Side block standard" width="192" height="128" />
            <add alias="sideBlockCarousel" name="Side block carousel" width="216" height="144" />
        </croppings>
    </cropUp>
    

    All good.  The crops are visible in the media section and seem to be saved when I save and re-visit.

    However, I'm now wanting to use the various crops in a template, so I set up an XSLT macro to test them, like this:

    <xsl:template match="/">
        <xsl:variable name="mediaId" select="umbraco.library:GetXmlNodeById(1242)/image" />
        <xsl:if test="$mediaId > 0">
            <h1>homepageCarousel:</h1>
            <img>
                <xsl:attribute name="src">
                    <xsl:value-of select="Eksponent.CropUp:UrlByMediaId($mediaId, 'homepageCarousel')" />
                </xsl:attribute>   
            </img>
            <h1>generalBanner:</h1>
            <img>
                <xsl:attribute name="src">
                    <xsl:value-of select="Eksponent.CropUp:UrlByMediaId($mediaId, 'generalBanner')" />
                </xsl:attribute>   
            </img>
            <h1>latestNewsEvents:</h1>
            <img>
                <xsl:attribute name="src">
                    <xsl:value-of select="Eksponent.CropUp:UrlByMediaId($mediaId, 'latestNewsEvents')" />
                </xsl:attribute>   
            </img>
            <h1>feature:</h1>
            <img>
                <xsl:attribute name="src">
                    <xsl:value-of select="Eksponent.CropUp:UrlByMediaId($mediaId, 'feature')" />
                </xsl:attribute>   
            </img>
            <h1>sideBlockStandard:</h1>
            <img>
                <xsl:attribute name="src">
                    <xsl:value-of select="Eksponent.CropUp:UrlByMediaId($mediaId, 'sideBlockStandard')" />
                </xsl:attribute>   
            </img>
            <h1>sideBlockCarousel:</h1>
            <img>
                <xsl:attribute name="src">
                    <xsl:value-of select="Eksponent.CropUp:UrlByMediaId($mediaId, 'sideBlockCarousel')" />
                </xsl:attribute>   
            </img>
        </xsl:if>
    </xsl:template>
    
    The image I've selected is straight from a camera: a jpeg at 2592x1944px.
    The output of this macro is weird.  I was expecting it to generate 6 images at different pixel dimensions: the first one at 936x390px, the second at 696x390, etc.  However, what it outputs is 6 images with the same URL, most of which are the original pixel dimensions.  The outupt is below (I've added the rendered pixel dimensions of each of the images in brackets):
    <h1>homepageCarousel:</h1>
    <img src="/CropUp/homepage/media/1003/dsc00285.jpg"> (this is output at 2592x1944px)
    
    <h1>generalBanner:</h1>
    <img src="/CropUp/general/media/1003/dsc00285.jpg"> (this is output at 2592x1944px)
    <h1>latestNewsEvents:</h1> <img src="/CropUp/latest/media/1003/dsc00285.jpg"> (this is output at 2592x1944px)
    <h1>feature:</h1> <img src="/CropUp/feature/media/1003/dsc00285.jpg"> (this is output at 456x304px)
    <h1>sideBlockStandard:</h1> <img src="/CropUp/side/media/1003/dsc00285.jpg"> (this is output at 2592x1944px)
    <h1>sideBlockCarousel:</h1> <img src="/CropUp/side/media/1003/dsc00285.jpg"> (this is output at 2592x1944px)

    I'm not sure if this is a bug with CropUp, a problem with compatability in Umbraco 6.1.1 or if I'm doing something wrong.

    Can anyone suggest what's up?

    Thanks

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Jun 18, 2013 @ 12:09
    Chriztian Steinmeier
    101

    Hi Dan,

    I've torn a few hairs out myself because of this - but the reason is because CropUp is case-sensitive with respect to the aliases - so they need to be lowercase and shouldn't contain any characters other than letters/numbers.

    As you can see, only the "feature" crop works as expected... the others get truncated at the first non-allowed character.

    /Chriztian

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jun 18, 2013 @ 12:10
    Jeroen Breuer
    0

    Did you try this on a 6.0 website? I'm using CropUp with Razor on 6.0 and I don't have any problems there. Maybe you could create a Razor file and try this in it:

    CropUp.GetUrl(umbracoFile, new ImageSizeArguments() { Width = 200, Height = 200 })

    Jeroen

  • Dan 1288 posts 3921 karma points c-trib
    Jun 18, 2013 @ 12:15
    Dan
    0

    Aaaaaaaahhhhhhh!  That's the one, thanks so much!  I thought I was being good copying the aliases directly from the config to the macro to make sure I'd discounted typos, but having to be ALL lowercase aliases would never have occurred to me!

    Thanks Chriztian, and congrats on the MVP - thoroughly deserved!

  • Dan 1288 posts 3921 karma points c-trib
    Jun 18, 2013 @ 12:16
    Dan
    0

    Thanks Jeroen. Hard-coding the dimensions in the crops worked, but the aliases didn't because of casing issues.  All sorted now, thanks.  (Congrats to you too on the MVP :)!)

Please Sign in or register to post replies

Write your reply to:

Draft