Automatic crop generation and XSLT for media items
I've just tried implementing this very nice package into a new site and have run into a few things I'm wondering about.
First of all, when I create a new image in the media section I need to save the image twice in order to get the cropped image generated. It would be more convenient if the generated image was created when you upload the image.
Second, I cannot find out how the XSLT for a media item should be. I managed to fix this by more or less hard-coding it, but should be easier doing it another way I would think.
That's more or less exactly my code! ;) I was more thinking about something similar to the code Kenny used on his blog, but seems like that works only with the content section.
I've just tested to see if the same XML is output in the Media section as it is in the Content, and it seems that it is (others would have been able to say straight out, but I'm just looking at the control for the first time).
As is mentioned in the blog post (which you've obviously seen), the image cropper outputs XML in the content tree, e.g.:
Just put your media node id into the right spot. Actually, with a tweak or two, this would show your entire media tree (and of course your standard content tree.
This topic is pretty old, but I wanted to let everyone know I've created 2 packages which can help with the Image Cropper (the default version in 4.5+).
Automatic crop generation and XSLT for media items
I've just tried implementing this very nice package into a new site and have run into a few things I'm wondering about.
First of all, when I create a new image in the media section I need to save the image twice in order to get the cropped image generated. It would be more convenient if the generated image was created when you upload the image.
Second, I cannot find out how the XSLT for a media item should be. I managed to fix this by more or less hard-coding it, but should be easier doing it another way I would think.
Hi Nikolas,
Here's what I've done:
Basically, I've split the media url using the '.', then take first part, add the crop name and finally add the extension (part after '.')
If there's a more convenient way, I'd like to hear about it...
Cheers,
/Dirk
Hi Dirk,
That's more or less exactly my code! ;) I was more thinking about something similar to the code Kenny used on his blog, but seems like that works only with the content section.
Nik
I've just tested to see if the same XML is output in the Media section as it is in the Content, and it seems that it is (others would have been able to say straight out, but I'm just looking at the control for the first time).
As is mentioned in the blog post (which you've obviously seen), the image cropper outputs XML in the content tree, e.g.:
<data alias="crops">
<crops date="14/09/2009 14:59:46">
<crop name="Thumb" x="307" y="121" x2="493" y2="254" url="/media/449/bookhouse-boys_3_Thumb.jpg"/>
<crop name="Full" x="0" y="0" x2="550" y2="350" url="/media/449/bookhouse-boys_3_Full.jpg"/>
</crops>
</data>
Note that the alias 'crops' is the alias of the Image Cropper property in the document type.
To use this in your XSLT, just reference the appropriate path with an XPath expression.
Of course, you'll be wanting to change that node Id reference to something different.
If you're keen to see the XML structure of the media item, try the following XSLT:
Just put your media node id into the right spot. Actually, with a tweak or two, this would show your entire media tree (and of course your standard content tree.
Hope this helps,
JT
I did it Dirk's way as well.
just splitting the media url and putting your cop-name between it.
This topic is pretty old, but I wanted to let everyone know I've created 2 packages which can help with the Image Cropper (the default version in 4.5+).
With the Digibiz Advanced Media Picker 2.0 Release Candidate it's possible to generate the crops on upload.
With the Create Crops package you can generate crops for all the media items to ensure all crops are available.
Jeroen
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.