Keyword
Please note that official support for commercial extensions & templates is provided in the Subscriber Help Desk.
Support requests should ONLY be directed there and require an active subscription plan.
This forum board is to be used for archive purposes and knowledge exchange ONLY.

Can I use my own thumbnails?

  • deanvandijk
  • deanvandijk's Avatar Topic Author
  • Offline
  • New Member
More
17 years 2 weeks ago #9277 by deanvandijk
Can I use my own thumbnails? was created by deanvandijk
I have detailed text images and their thumbnails look the same. I would like to  create my own thumbnails instead of the thumbnails generated. Is this possible?

Dean.

Please Log in or Create an account to join the conversation.

  • JoomlaWorks Support Team
  • JoomlaWorks Support Team's Avatar
  • Offline
  • Platinum Member
More
17 years 1 week ago #9278 by JoomlaWorks Support Team
Replied by JoomlaWorks Support Team on topic Re: Can I use my own thumbnails?
Hi my friend!

I'm afraid that you can't do it with this version of sig pro!
We create the thumbs and we rename them with a specific name!

Also, you can just replace the thumbs that the sig pro create
with your thumbs but must keep the thumbs name that sig pro gives!

Thank you!

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • deanvandijk
  • deanvandijk's Avatar Topic Author
  • Offline
  • New Member
More
17 years 1 week ago #9279 by deanvandijk
Replied by deanvandijk on topic Re: Can I use my own thumbnails?
I have tried replacing the thumbnail files in the temp folder but the changes do not take effect and the thumbnails appear to be refreshed regularly (looking at file creation date/times in this temp folder).

Any more ideas?

Please Log in or Create an account to join the conversation.

  • JoomlaWorks Support Team
  • JoomlaWorks Support Team's Avatar
  • Offline
  • Platinum Member
More
17 years 1 week ago - 17 years 1 week ago #9280 by JoomlaWorks Support Team
Replied by JoomlaWorks Support Team on topic Re: Can I use my own thumbnails?
hi my friend!

check this post for the bug

the thumbnails appear to be refreshed regularly


and retry to replace the thumbs with yours!

also you can modify the line
// create thumbnails
if (file_exists($mosConfig_absolute_path.$tempfolder.md5($_images_dir_.$name).".".$format) && filemtime ($mosConfig_absolute_path.$tempfolder.md5($_images_dir_.$name).".".$format) && $cache_expire_time * 60 > time()) {
with
// create thumbnails
if (file_exists($mosConfig_absolute_path.$tempfolder.md5($_images_dir_.$name).".".$format) ) {
if you don't want the cache checking!

Thank you!

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • deanvandijk
  • deanvandijk's Avatar Topic Author
  • Offline
  • New Member
More
17 years 1 week ago #9281 by deanvandijk
Replied by deanvandijk on topic Re: Can I use my own thumbnails?
The closest I could find was this...

// create thumbnails

if (file_exists($tempfolder.md5($_images_dir_.$name).$format) && filemtime ($tempfolder.md5($_images_dir_.$name).$format) + $cache_expire_time * 60 > time()) {


I should just remove

+ $cache_expire_time * 60 > time()

Please Log in or Create an account to join the conversation.

More
17 years 3 days ago #9282 by Mark Beddis
Replied by Mark Beddis on topic Re: Can I use my own thumbnails?
This is a hack - i needed to achieve the result fast to verify I could use SIG Pro. 

Edit the sigpro_engine.php file in the /mambots/content/plugin_jw_sigpro/ folder and replace the GenerateThumbFile($from_name, $to_name) function with this one. 


Below your sig_image folder ({gallery}sig_image{/gallery}) create a folder called thumbnails.  Copy your main images to this new thumbnail images folder and edit or resize them as required maintaining the same filenames.  When you run a page with {gallery}sig_image{/gallery} the new thumbnails are generated from the new thumnails folder content whilst the main pop-up images are generated from the sig_image folder.

Important - before using the modified function you must make sure you delete all current pre-generated images from the temp folder.

This code has no error checking in to make sure the thumbnails folder exists or indeed the images - it is quick and dirty but it works so maybe you can tidy it up and make it useful.  I am new to joomla and PHP - hence the noddy code!


  // generate thumb from image and save it

  function GenerateThumbFile($from_name, $to_name) {



    // get source image size (width/height/type)

    // orig_img_type 1 = GIF, 2 = JPG, 3 = PNG
$thumb_from_name = null;
$echo_thumb_from_name = null;


 
 
  // First check if there is a "/" at position 0.
if(strpos($from_name, "/") == 0){
$fiveCounter++;

}

// Check the rest of the string for 5's
while($offset = strpos($from_name, "/", $offset + 1)){
$fiveCounter++;
$lastoffset = $offset;
}

$thumb_from_name = substr($from_name, 0, $lastoffset);
$thumb_from_name .= "/thumbnails/";

$offset1 = $lastoffset + 1;
$offset2 = strlen($from_name) - $lastoffset;

$thumb_from_name .= substr($from_name, $offset1, $offset2 );


 

    list($orig_x, $orig_y, $orig_img_type, $img_sizes) = GetImageSize($thumb_from_name);



    // cut image if specified by user

    if ($this->cut_x > 0) $orig_x = min($this->cut_x, $orig_x);

    if ($this->cut_y > 0) $orig_y = min($this->cut_y, $orig_y);



    // should we override thumb image type?

    $this->image_type = ($this->image_type != -1 ? $this->image_type : $orig_img_type);



    // check for allowed image types

    if ($orig_img_type < 1 or $orig_img_type > 3) die("Image type not supported");



    if ($orig_x > $this->max_x or $orig_y > $this->max_y) {



      // resize

      $per_x = $orig_x / $this->max_x;

      $per_y = $orig_y / $this->max_y;

      if ($per_y > $per_x) {

        $this->max_x = $orig_x / $per_y;

      }

      else {

        $this->max_y = $orig_y / $per_x;

      }



    }

    else {

      // keep original sizes, i.e. just copy

      if ($this->save_to_file) {

        @copy($thumb_from_name, $to_name);

      }

      else {

        switch ($this->image_type) {

          case 1:

              header("Content-type: image/gif");

              include($thumb_from_name);

            break;

          case 2:

              header("Content-type: image/jpeg");

              include($thumb_from_name);

            break;

          case 3:

              header("Content-type: image/png");

              include($thumb_from_name);

            break;

        }

      }

      return;

    }



    if ($this->image_type == 1) {

      // should use this function for gifs (gifs are palette images)

      $ni = imagecreate($this->max_x, $this->max_y);

    }

    else {

      // Create a new true color image

      $ni = ImageCreateTrueColor($this->max_x,$this->max_y);

    }



    // Fill image with white background (255,255,255)

    $white = imagecolorallocate($ni, 255, 255, 255);

    imagefilledrectangle( $ni, 0, 0, $this->max_x, $this->max_y, $white);

    // Create a new image from source file

    $im = $this->ImageCreateFromType($orig_img_type,$thumb_from_name);

    // Copy the palette from one image to another

    imagepalettecopy($ni,$im);

    // Copy and resize part of an image with resampling

    imagecopyresampled(

      $ni, $im,            // destination, source

      0, 0, 0, 0,          // dstX, dstY, srcX, srcY

      $this->max_x, $this->max_y, // dstW, dstH

      $orig_x, $orig_y); // srcW, srcH



    // save thumb file

    $this->SaveImage($ni, $to_name);

  }



}

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum