We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4414
    • 63 Posts
    Hi,

    I am looking for a plugin that automatically resamples images after manually resizing them in TinyMCE. The original image should be kept untouched while a resampled copy is stored in another folder. Up to know the size of a resized image does not change but only gets scaled, as can be seen in the image properties: Image Dimensions: 146px × 269px (scaled to 105px × 188px)

    I would like to know if there is a plugin in Modx or TinyMCE to achieve this goal? This feature would save me a lot bandwidth as users often upload very large pictures.

    Looking forward to your reply!
      • 4310
      • 2,310 Posts
      You might consider DirectResize.
      I can’t see it in the new repository bt the forum thread is here.
        • 4414
        • 63 Posts
        Hi bunk58,

        Thanks for your advice. I found the current version of DirektResize on Google Code: http://code.google.com/p/directresize-modx/updates/list
        An automatic translation of the Russian readme file can be found here: http://modx.metaller.ru/assets/plugins/directresize/docs/readme_ru.html" target="_blank" rel="nofollow">http://translate.google.com/translate?hl=ru&sl=ru&tl=en&u=http://modx.metaller.ru/assets/plugins/directresize/docs/readme_ru.html
          • 15469
          • 64 Posts
          Katzenfutter Reply #4, 15 years ago
          Quote from: Bytesource at Mar 21, 2009, 10:16 AM

          Hi,

          I am looking for a plugin that automatically resamples images after manually resizing them in TinyMCE.

          Hi there,

          you might have a look at this:
          "your_modx_path/manager/media/browser/mcpuk/connectors/php/Commands/Thumbnail.php"

          You can easily edit it to have the thumbnail you wish.
          /**
          	 * Size of preferred thumbnail
          	 * @int unknown_type
          	 */
          	var $preferred_size = 200;
          	
          	/**
          	 * Color Red
          	 * @int color
          	 */
          	var $red = 255;
          	
          	/**
          	 * Color Green
          	 * @int color
          	 */
          	var $green = 255;
          	
          	/**
          	 * Color Blue
          	 * @int color
          	 */
          	var $blue = 239;
          
          
          ...
          
          function resizeImage($img) {
          		//Get size for thumbnail
          		$width=imagesx($img); $height=imagesy($img);
          		if ($width>$height) { $n_height=$height*($this->preferred_size/$width); $n_width=$this->preferred_size; } else { $n_width=$width*($this->preferred_size/$height); $n_height=$this->preferred_size; }
          		
          		$x=0;$y=0;
          		if ($n_width<$this->preferred_size) $x=round(($this->preferred_size-$n_width)/2);
          		if ($n_height<$this->preferred_size) $y=round(($this->preferred_size-$n_height)/2);
          		
          		$thumb=imagecreatetruecolor($this->preferred_size,$this->preferred_size);
          		
          		#Background colour fix by:
          		#Ben Lancaster ([email protected])
          		$bgcolor = imagecolorallocate($thumb,$this->red, $this->green, $this->blue);
          		imagefill($thumb, 0, 0, $bgcolor);
          		
          		if (function_exists("imagecopyresampled")) {
          			if (!($result=@imagecopyresampled($thumb,$img,$x,$y,0,0,$n_width,$n_height,$width,$height))) {
          				$result=imagecopyresized($thumb,$img,$x,$y,0,0,$n_width,$n_height,$width,$height);
          			}	
          		} else {
          			$result=imagecopyresized($thumb,$img,$x,$y,0,0,$n_width,$n_height,$width,$height);
          		}
          
          		return ($result)?$thumb:false;
          	}
          
          


          I wanted to have the background to appear in a more yellow-like color, the size of each .thumb 200x200pixels.
          The directory where the thumbs are being stored can be easily changed... No need for an extra snippet/module.

          function Thumbnail($fckphp_config,$type,$cwd) {
          ...
          $this->real_cwd=str_replace("//","/",($this->fckphp_config['basedir']."/".$this->actual_cwd));
          ...
          }
          ...
          var $cwd;
          	var $actual_cwd;
          	var $filename;
          ...
          function run() {
          		//$mimeIcon=getMimeIcon($mime);
          		$fullfile=$this->real_cwd.'/'.$this->filename;
          		$thumbfile=$this->real_cwd.'/.thumb_'.$this->filename;
          ...
          }
          



          Cheers
            $cd /pub
            $more beer