Don't give up yet, a solution has appeared on the horizon!
Kenn has just submitted a pull request to automatically convert JSON datatype content to XML when saving to the content cache. Which means that the image cropper is usable from XSLT, as are all other datatypes that save JSON. And the entire content cache is queryable in XSLT (querying blobs of JSON in CDATA is pretty useless).
Has this been solved at all? I'd love to use the imagecropper in my v7 site, but I've already created all my xlst files. I'm horrible at razor and don't want to have to spend weeks trying to get the same things done in razor. To make things more complicated, my original solution included imagegen. Replacing the pageLinkImage line with the one below doesn't give the results I need.
Hi Wade - I know @Dammark has been doing some stuff here on Github - maybe you can just use that, or at least see how it's done. It handles the focal point etc.
Thank you very much for pointing me in the direction of @Danmark. Sebastian was able to help me get it working.
If anyone wants to use imagecropper in Umbraco 7 with xslt it is possible. Follow Chriztian's link above and follow the instructions on Sebastian's github page. In my case however, I am uploading the image straight to the content, not via the media section. Sebastian sent me a different _MediaHelper.xslt that worked for me. I'll post it below.
Steps:
1. Create a new clean xslt file and call it _MediaHelper.xslt and paste in the following code (_MediaHelper.xslt code from Sebastian Danmark):
That's it. It worked for me after that. The crop name in the last bit of code is the actual name of the crop in the imagecropper data type.
One thing to be aware of though, is that if you are implementing this after you have put the images in your site, you will have to re-upload the images that are used in the image cropper. In umbraco it looks like they are there, but they won't show on the page until you have re-uploaded them.
Huge thanks to Chriztian Steinmeier and Sebastian Danmark.
Im trying to use this to in a slideshow and I can get the images by serving the Folders Id but i want to wrap each image in an li element. Where can I add this?
Hmm...When I try to Visualize the xslt I get the following error:
Error parsing the XSLT:
System.Xml.Xsl.XslLoadException: XSLT compile error. An error occurred at (14,42). ---> System.IO.FileNotFoundException: Could not find filec:\windows\system32\inetsrv\_MediaHelper.xslt.
Ive just added <xsl:include href="MediaHelper.xslt" />?
Unfortunately, the Visualizer doesn't work with includes (or a couple of other similar features, e.g., external entities) - I think it's because Umbraco copies the file to a temp directory, so the included file can't be reached...
How to get image cropper value
Hi
Image trying to get a new kind of cropper to work. But cant get any further than this
My image has a properti: imageCrop
And when i'm passing this out with
<xsl:value-of select="umbraco.library:GetMedia($currentPage/size300, 0)/imageCrop" />
And it gives me:
[ { "id": "MainCrop", "x1": 30, "y1": 41, "x2": 330, "y2": 341, "widthoriginal": 1152, "heightoriginal": 864, "widthdisplay": "300", "heightdisplay": "300", "compression": "90", "resizewidth": 477.00000000000011, "cropcoords": "72,99,725,725", "previewurl": "/media/1001/lily-flower-wallpaper3.jpg?crop=72,99,725,725&width=300&quality=90" } ]
And i've located the image to here at this part:
"previewurl": "/media/1001/lily-flower-wallpaper3.jpg?crop=72,99,725,725&width=300&quality=90"
But how do i grap the image url?
Hi Mads,
Looks like you are using the v7 image cropper package with XSLT!
I haven't tried it myself but I believe that there is a new JSON to XML XSLT helper for doing just this.
See this blog post by Tim Geyssens for more information
Jeavon
Hi Mads,
I would really recommend getting a .NET dev to code an extension for you, so that you can do something like this:
Otherwise, you'll be in a world of pain trying to string-manipulate your way through this...
JSON is a horrible format to use from XSLT - just like XML is a horrible format to use from JavaScript :-)
(I actually think Umbraco 7 has an extension like that already...)
Update: Yes, it has - U4-3581
/Chriztian
Hi Guys
Thanks for the answer i've downgrated my solution to an 6.1.6.
I think that i'm getting forced to learn Razor instead of my beloved XSLT :D
Still pretty new in Razor thats why i downgrated - using CropUp insted :D
Thanks for the helt anyway :D
Don't give up yet, a solution has appeared on the horizon!
Kenn has just submitted a pull request to automatically convert JSON datatype content to XML when saving to the content cache. Which means that the image cropper is usable from XSLT, as are all other datatypes that save JSON. And the entire content cache is queryable in XSLT (querying blobs of JSON in CDATA is pretty useless).
Rally around the Alliance, cast your vote! :)
Has this been solved at all? I'd love to use the imagecropper in my v7 site, but I've already created all my xlst files. I'm horrible at razor and don't want to have to spend weeks trying to get the same things done in razor. To make things more complicated, my original solution included imagegen. Replacing the pageLinkImage line with the one below doesn't give the results I need.
<a class="megamenupic" href="{umbraco.library:NiceUrl(@id)}"> <img> <xsl:attribute name="class"><xsl:text>img-responsive</xsl:text></xsl:attribute> <xsl:attribute name="alt"><xsl:value-of select="@nodeName"/></xsl:attribute> <xsl:attribute name="src"> <xsl:text>/imagegen.ashx?image=</xsl:text> <xsl:value-of select="umbraco.library:JsonToXml($currentPage/pageLinkImage)"/> <xsl:text>&width=400</xsl:text><xsl:text>&AltImage=images/placeholder.gif</xsl:text> </xsl:attribute> </img></a>
It spits out the following:
Obviously not what I want.
Is this an impossible task or is it just too difficult to attempt?
Cheers,
Wade.
Hi Wade
Actually, I moved over to Razor, it has made my life a little easier with the new umbraco 7 :)
But anyways thanks for your reply :)
Hi Wade - I know @Dammark has been doing some stuff here on Github - maybe you can just use that, or at least see how it's done. It handles the focal point etc.
/Chriztian
Hi Chriztian,
Thank you very much for pointing me in the direction of @Danmark. Sebastian was able to help me get it working.
If anyone wants to use imagecropper in Umbraco 7 with xslt it is possible. Follow Chriztian's link above and follow the instructions on Sebastian's github page. In my case however, I am uploading the image straight to the content, not via the media section. Sebastian sent me a different _MediaHelper.xslt that worked for me. I'll post it below.
Steps:
1. Create a new clean xslt file and call it _MediaHelper.xslt and paste in the following code (_MediaHelper.xslt code from Sebastian Danmark):
2. In the top of the xslt file that you are using to call the imagecropper image, add in this line of text:
3. Still in the xslt file that you are using to call the imagecropper image, when you want the image to appear, add this line of text:
That's it. It worked for me after that. The crop name in the last bit of code is the actual name of the crop in the imagecropper data type.
One thing to be aware of though, is that if you are implementing this after you have put the images in your site, you will have to re-upload the images that are used in the image cropper. In umbraco it looks like they are there, but they won't show on the page until you have re-uploaded them.
Huge thanks to Chriztian Steinmeier and Sebastian Danmark.
Hi!
Im trying to use this to in a slideshow and I can get the images by serving the Folders Id but i want to wrap each image in an li element. Where can I add this?
Hmm...When I try to Visualize the xslt I get the following error:
Error parsing the XSLT:
System.Xml.Xsl.XslLoadException: XSLT compile error. An error occurred at (14,42). ---> System.IO.FileNotFoundException: Could not find file c:\windows\system32\inetsrv\_MediaHelper.xslt.
Ive just added <xsl:include href="MediaHelper.xslt" />?
Hi Froad
Shouldn't you reference the _MediaHelper.xslt file? so the include should say
<xsl:include href="_MediaHelper.xslt" />
?/Jan
That was a mistype by me when adding the post. I am referencing _MediaHelper.xslt. But why is it looking in c:\windows\system32\inetsrv?
Hi Froad
Ok, where have you placed the reference to the entities file? I assume you found the files here https://github.com/greystate/Greystate-XSLT-Helpers/tree/master/mediahelpers
/Jan
No, I used the following:https://github.com/sebastiandammark/umbraco7-xslt-helpers/tree/master/MediaHelper
Hi froad,
Unfortunately, the Visualizer doesn't work with includes (or a couple of other similar features, e.g., external entities) - I think it's because Umbraco copies the file to a temp directory, so the included file can't be reached...
/Chriztian
is working on a reply...