WebsiteBaker Support (2.13.x) > General Help & Support

Cropping and resizing images using framework/media/inc/PhpThumbFactory

(1/2) > >>

CodeALot:
Currently I use SLIR to resize and crop images to fit in my templates. My hoster changed the open_basedir restriction and now SLIR fails because of that.

I see in framework/media/inc/PhpThumbFactory that Imagick can be used to do this. How would I implement this? Do I need to call the framework somewhere?

Below is the part of the code from overview.php in OneForAll that I use to resize and crop the images (see: SLIR)


--- Code: ---                // Make array of all item thumbs and images
                if (file_exists($thumb_dir.$thumb_file) && file_exists($img_dir.$image_file)) {
                    // If needed add lightbox2 link to the thumb/image...
                    if ($setting_lightbox2 == 'overview' || $setting_lightbox2 == 'all') {
                        $thumb_prepend = '<a href="'.$img_url.$image_file.'" data-lightbox="lightbox[image_'.$item_id.']" title="'.$img_title.'"><img src="';
                        $img_prepend   = '<a href="'.$img_url.$image_file.'" data-lightbox="lightbox[image_'.$item_id.']" title="'.$img_title.'"><img src="';
                        $thumb_append  = '" alt="'.$img_alt.'" title="'.$img_title.'" class="mod_'.$mod_name.'_main_thumb_f" /></a>';
                        $img_append    = '" alt="'.$img_alt.'" title="'.$img_title.'" class="mod_'.$mod_name.'_main_img_f" /></a>';
                    // ...else add thumb/image only
                    } else {
                        // Add link to detail pages
                        if ($view_detail_pages) {
                            $thumb_prepend = '<a href="'.$item_link.'"><img src="';
                            $thumb_append  = '" alt="'.$img_alt.'" title="'.$img_title.'" class="mod_'.$mod_name.'_main_thumb_f" /></a>';
                        // No detail pages therefor no link needed
                        } else {
                            $thumb_prepend = '<img src="';
                            $thumb_append  = '" alt="'.$img_alt.'" title="'.$img_title.'" class="mod_'.$mod_name.'_main_thumb_f" />';
                        }
                        $img_prepend   = '<img src="/slir/w640-h460-c640x460';
                        $img_append    = '" alt="'.$img_alt.'" title="'.$img_title.'" class="mod_'.$mod_name.'_main_img_f" />';
                    }
                    // Make array
                    $thumb_arr[] = $thumb_prepend.$thumb_url.$thumb_file.$thumb_append;
                    $image_arr[] = $img_prepend.$img_url.$image_file.$img_append;

--- End code ---

sternchen8875:

--- Quote from: CodeALot on June 12, 2024, 10:17:14 AM ---I see in framework/media/inc/PhpThumbFactory that Imagick can be used to do this. How would I implement this? Do I need to call the framework somewhere?

--- End quote ---

Imagick is a optional software, not installed on every server. Some providers also offer the package for a fee, which is why WB does not offer direct use.

the software has a intern check, is Imagick installed or not, so its not needed, to activate anything

for the code: not possible for me, to help here, i'm not using it. But take a look into the folder /admin/media
there we use the PhpThumbFactory to resize and display pictures, also in a zip-upload

CodeALot:
Thanks! Will look into that. Doesn't seem too complicated :-)

crnogorac081:
so this is like on-the-fly cropping using original image, where you dont create new cropped image, or you would like to create new image ? If so I can post good php class

hgs:
A good php class is always welcome, even for the developers. ;)

Navigation

[0] Message Index

[#] Next page

Go to full version