• Welcome to WebsiteBaker Community Forum. Please log in or sign up.
Welcome, Guest
News
Support WebsiteBaker
Your donations will help to:
PayPal
  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!
You can donate by clicking on the button below.

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

Started by CodeALot, June 12, 2024, 10:17:14 AM  ( Read 30,025 times )

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)

// 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;

    Gast

    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?

    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


      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
        Web developer

        hgs

        A good php class is always welcome, even for the developers. ;)
          LG Harald

          "Fange nie an, aufzuhören - höre nie auf, anzufangen." Marcus Tullius Cicero (106-43 v.Chr.)

          "Never begin to stop - never stop beginning." Marcus Tullius Cicero (106-43 BC)


          hgs

          LG Harald

          "Fange nie an, aufzuhören - höre nie auf, anzufangen." Marcus Tullius Cicero (106-43 v.Chr.)

          "Never begin to stop - never stop beginning." Marcus Tullius Cicero (106-43 BC)


          \n\n