WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.8 is now available!


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.13.x) »
  • General Help & Support »
  • Cropping and resizing images using framework/media/inc/PhpThumbFactory
  • Print
Pages: [1]   Go Down

Author Topic: Cropping and resizing images using framework/media/inc/PhpThumbFactory  (Read 24751 times)

Offline CodeALot

  • Posts: 579
  • Gender: Male
Cropping and resizing images using framework/media/inc/PhpThumbFactory
« on: June 12, 2024, 10:17:14 AM »
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: [Select]
                // 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;
Logged

Offline sternchen8875

  • Global Moderator
  • *****
  • Posts: 609
Re: Cropping and resizing images using framework/media/inc/PhpThumbFactory
« Reply #1 on: June 12, 2024, 11:52:30 AM »
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
Logged

Offline CodeALot

  • Posts: 579
  • Gender: Male
Re: Cropping and resizing images using framework/media/inc/PhpThumbFactory
« Reply #2 on: June 12, 2024, 12:12:41 PM »
Thanks! Will look into that. Doesn't seem too complicated :-)
Logged

Offline crnogorac081

  • Posts: 2163
  • Gender: Male
Re: Cropping and resizing images using framework/media/inc/PhpThumbFactory
« Reply #3 on: June 12, 2024, 02:30:51 PM »
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
Logged
Web developer

Offline hgs

  • WebsiteBaker Org e.V.
  • **
  • Posts: 1892
    • EFG MG
Re: Cropping and resizing images using framework/media/inc/PhpThumbFactory
« Reply #4 on: June 12, 2024, 02:52:49 PM »
A good php class is always welcome, even for the developers. ;)
Logged
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)

Offline crnogorac081

  • Posts: 2163
  • Gender: Male
Re: Cropping and resizing images using framework/media/inc/PhpThumbFactory
« Reply #5 on: June 13, 2024, 08:55:39 AM »
this one https://github.com/sprain/class.Images.php
Logged
Web developer

Offline hgs

  • WebsiteBaker Org e.V.
  • **
  • Posts: 1892
    • EFG MG
Re: Cropping and resizing images using framework/media/inc/PhpThumbFactory
« Reply #6 on: June 13, 2024, 06:13:18 PM »
 (Y)
Logged
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)

Offline CodeALot

  • Posts: 579
  • Gender: Male
Re: Cropping and resizing images using framework/media/inc/PhpThumbFactory
« Reply #7 on: July 01, 2024, 12:52:06 PM »
Quote from: crnogorac081 on June 13, 2024, 08:55:39 AM
this one https://github.com/sprain/class.Images.php
Thanks a lot!
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.13.x) »
  • General Help & Support »
  • Cropping and resizing images using framework/media/inc/PhpThumbFactory
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2