External image block
chopinhauer
Joined: 2004-06-21
Posts: 9 |
Posted: Sat, 2005-05-21 11:40 |
While adding the G2 image block to my site I noticed that the imageblock:External options are quite minimal. For example my original size pictures are all taken with a 4MPix camera so I cannot put them in an image block (it would be a waste of bandwidth for both the server the client) nor want I put just the thumbnail (cf. my Main Page for what I use image block for). Another misfeature is that 'fullSize' gives you the original image and not the preferred source, so pictures that are rotated look horrible. Personally I modified the ImageBlockHelper.class to select the preferred source if you give the 'fullSize' parameter. If you don't use 'fullSize' but you give a 'maxSize' it selects the biggest resize that matches the restriction (but maybe the smallest resize that is bigger than 'maxSize' would be more appropriate). I include the diff against beta3. Feel free to use it if you consider it useful. Piotr PS: Thank you for the great job with G2. Even if I know little of PHP, to modify the source code is very easy and intuitive. Index: ImageBlockHelper.class =================================================================== RCS file: /home/karwasz/cvsroot/karwasz.org/gallery2/modules/imageblock/classes/ImageBlockHelper.class,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -r1.1.1.2 -r1.2 86c86,87 < $itemType, $order, $parentId, $fullSize); --- > $itemType, $order, $parentId, $fullSize, > (isset($params['maxSize']) ? $params['maxSize'] : 0)); 131c132,133 < function _addBlock(&$blocks, $title, $itemType, $order, $parentId=null, $fullSize=false) { --- > function _addBlock(&$blocks, $title, $itemType, $order, $parentId=null, > $fullSize=false, $maxSize=false) { 238,239c240,260 < $image = $item; < } else { --- > list ($ret, $preferred) = GalleryCoreApi::fetchPreferredSource($item); > if ($ret->isError()) { > return GalleryStatus::success(); > } > $image = $preferred; > } else if ($maxSize) { > list ($ret, $resizes) = GalleryCoreApi::fetchResizesByItemIds(array($id)); > if ($ret->isError()) { > return $ret->wrap(__FILE__, __LINE__); > } > > $bestSize = 0; > foreach ($resizes[$id] as $resize) { > $size = max($resize->getWidth(), $resize->getHeight()); > if (($size <= $maxSize) and ($size >= $bestSize)) { > $image = $resize; > $bestSize = $size; > } > } > } > if (!isset($image)) { |
|
Posts: 1
Hi!
This is exactly what I need...
... any chance you have migrated this to v.2?
Thanx,
nonZero
Posts: 5
This is my first patch to Gallery2, thanks chopinhauer!
Gallery 2.1.2 core 1.1.0.2, ImageBlock 1.0.8
[edit] Add code to deal with none resized version.
Note: Current code only works with Image mode
Posts: 5
It's hard for newcomers to get info about the api $parm...
Here comes the "error message free" update, only deals with 'GalleryDataItem', i.e. image only.
Posts: 5
Since I'm only good at copy & paste for minor functional mods, with minimal programming skills.
Can someone help me to understand how to get 'GalleryDataItem' from 'GalleryAlbumItem'?