Automatic Image Resize in Slideshow?
Thanks for your direction,
here's a demo if you want to play around with it:
Copy /concrete/blocks/slideshow/view.php to /block/slideshow/view.php
In the new view.php around line 89 look for
fullFilePath:"<?php echo $f->getRelativePath()?>",
<?php $ih = Loader::helper('image'); ?> fullFilePath:"<?php echo $ih->getThumbnail($f, 300, 200)->src; ?>",
replace the 300, 200 with whatever dimensions you want.
This will scale the images proportionally into whatever size window you want. If you want it to crop let me know and I can provide some more code.
Hope that helps!
by the way... I didn't test the above code... but it should work
EDIT: just realized I put the image helper code into a loop... and it will be re-loaded for every image. The line
<?php $ih = Loader::helper('image'); ?>
EDIT 2: of course this will make any slideshow block on your site whatever dimensions you specify... but you can create custom templates for each size you need... or get fancy and fork the block to add width and height variables.
Change line 22 to reflect the height of the thumbnails:
line 29 to:
line 95 to:
seemed to be PERFECT at first...
then I noticed a large space at the top. Any idea why? Seems like a large margin or padding on the top, but I used shaned's code to make the margin 0:
isn't that what it does?
I'm imagining that it's just that the image's ratio is wider than the box you're sizing it into.
I'm a PHP noob so I don't know... is it difficult to write client-side sizing into the slideshow control panel? My guess is YES, EXTREMELY FOR A NOOB, but probably not at all for a pro.
There are also instructions on use in the same thread. Apparently this will be included in the Concrete5 core as part of the next release.
If you want the user to crop an image manually in C5, the only way I know about currently is to use the Picnik editor. In the File Manager click on an image and choose Edit.
Then update your getThumbnail method call to include the new array.
If you start with:
you'd change it to
That should be it!
If you want the user to set the slideshow dimensions you'll need to learn about working with custom blocks. You'd need to update the add/edit form, the database set-up, and the block template.
For a newcomer, I'd suggest looking at custom templates first. You could provide a few different templates with different size choices.
Here's a tutorial about that:
Grab it here:http://www.mesuva.com.au/blog/technical-notes/a-slideshow-plugin-fo...