Jump to content

Archived

This topic is now archived and is closed to further replies.

oscMarket

Dynamic thumbnails

Recommended Posts

In includes/html_output.php,

FIND:
 

////
// The HTML image wrapper function
  function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '', $responsive = true, $bootstrap_css = '') {
    if ( (empty($src) || ($src == 'images/')) && (IMAGE_REQUIRED == 'false') ) {
      return false;
    }

AFTER ADD:
 

    if (is_file($src) && tep_not_null($width) && tep_not_null($height)) {
        require_once('ext/gumlet/ImageResize.php');        

        if (!is_dir(DIR_FS_CATALOG . 'images/' . $width . 'x'. $height)) {
            mkdir(DIR_FS_CATALOG . 'images/' . $width . 'x'. $height, 0755, true);
        }
        $new_image = end(explode('/',$src));
        $path = 'images/' . $width . 'x'. $height . '/'. $new_image;
        if (!file_exists($path)){
            $OSCOM_Thumb = new ImageResize($src);
            $OSCOM_Thumb->resize($width,$height, true);
            $OSCOM_Thumb->save($path, true);
        }    
        if(file_exists($path)){
            $src = $path;
        }
    }

in ext create directory called gumlet
Within add the attached file:


 

ImageResize.php

Share this post


Link to post
Share on other sites

Greetings,

 

Is there any way of overlaying a div over the tep_image() function call and trigger the colorbox in product_info.php?

It would be handy to overlay some css div for "out of stock" info, for example.

Best regards,

Luis Xavier

Share this post


Link to post
Share on other sites

@Owl Sauron 

Only a watermark
https://github.com/gumlet/php-image-resize
 

$image = new ImageResize('image.jpg');

// Add banner on bottom left corner
$image18Plus = 'banner.png'
$image->addFilter(function ($imageDesc) use ($image18Plus) {
    $logo = imagecreatefrompng($image18Plus);
    $logo_width = imagesx($logo);
    $logo_height = imagesy($logo);
    $image_width = imagesx($imageDesc);
    $image_height = imagesy($imageDesc);
    $image_x = $image_width - $logo_width - 10;
    $image_y = $image_height - $logo_height - 10;
    imagecopy($imageDesc, $logo, $image_x, $image_y, 0, 0, $logo_width, $logo_height);
});

 

Share this post


Link to post
Share on other sites

Excellent addon @wHiTeHaT

I think it would be better to put everything together in a .ZIP and upload it as an addon to the market.
Here in the forum will be lost in a few days ....

Best regards

Valqui


Setting up a new Frozen site with so many nice addons available on the market and waiting to be admitted to Phoenix club!

Community Oscommerce fan :heart:

 

Share this post


Link to post
Share on other sites
20 hours ago, wHiTeHaT said:

Cool thumbnailscript, but it will throw many errors if the source image, for whatever reason, does not exist.

Do you have a fix for that?


:heart: osCommerce

I am using osCommerce CE Phoenix.

Get the latest Responsive osCommerce CE (community edition) here

 

Share this post


Link to post
Share on other sites
4 hours ago, Rwe said:

Cool thumbnailscript, but it will throw many errors if the source image, for whatever reason, does not exist.

 

Yeah... make sure it does.
 

But i changed the code from the first post, so you will not get any error for that anymore.

Share this post


Link to post
Share on other sites
1 hour ago, wHiTeHaT said:

so you will not get any error for that anymore.

 @wHiTeHaT Ok thanks, It still does if an image is missing:

Warning: finfo_file(images/dvd/speed.gif): failed to open stream: No such file or directory in  xxx..

Warning: getimagesize(images/dvd/speed.gif): failed to open stream: No such file or directory in xxx..

i changed 

        if ($filename === null || empty($filename) || (substr($filename, 0, 7) !== 'data://' && !is_file($filename))) {
            $this->error[] = 'File does not exist'; 
        }

to

        if ($filename === null || empty($filename) || (substr($filename, 0, 7) !== 'data://' && !is_file($filename))) {
            $this->error[] = 'File does not exist';
           $filename = 'images/no-image.png';
        }

Its working now with a no-image.png but maybe there is a better way of fixing this.


:heart: osCommerce

I am using osCommerce CE Phoenix.

Get the latest Responsive osCommerce CE (community edition) here

 

Share this post


Link to post
Share on other sites

Yes..... i made a mistake, but you should not change that code within the ImageResize.php.
just:
 

    if (is_file($src) && tep_not_null($width) && tep_not_null($height)) {
        require_once('ext/gumlet/ImageResize.php'); 


Post updated.

Share this post


Link to post
Share on other sites

×