Content last modified Monday 3 September 2018
hop to #bottom
Current version:
About It:
Get it:
Rate it:
  • Helpful?
  • 1 Yes
  • 2 No
Flag it:

If you'd like to provide updated information and do not have access to directly edit, please contact the site admin; thanks!

mdp_automatic_randt mod

TXP Hack to automatically create thumbnails from uploaded JPEG’s

This is another TXP g1.19 hack that lets you automatically create thumbnails when a JPEG image is uploaded. It also will resize the uploaded image if it is too large. This makes uploading photos really easy, because the server will handle everything and help you save space by not keeping high resolution photos on your account.

(For a version that works in RC3, see Daniel’s customized mdp_automatic_randt .)


In version 0.5 there are four options that can be found on lines #13-16:

  • “RT_RESIZE” => Image width, in pixel’s, that you want the uploaded image to be resized to. If the original is smaller than this, it won’t be resized.
  • “RT_TW” => Width of the thumbnail, in pixel’s. Setting to -1 will disable thumbnail creation.
  • “RT_TH” => Height of the thumbnail, in pixel’s. Setting to -1 will also disable thumbnail creation, and setting to 0 will make the thumbnail the same aspect ratio as the original image. Setting to the same value as “thumbw” will create square pixel’s, any other values will make the height that value (may cause distortion).
  • “RT_IMAGICK” => Enable ImageMagick or not, setting to 1 (default) will turn ImageMagick ON.


Installation isn’t as easy as a regular plugin, but trust me you can do it!

  1. Download mdp_automatic_randt
  2. Rename /textpattern/include/txp_image.php to txp_image.original
  3. Put “mdp_automatic_randt.v0.5.1.txt” into /textpattern/include/
  4. Rename “mdp_automatic_randt.v0.5.1.txt” to “txp_image.php”

Additional Information

If your server has ImageMagick installed (many do), I would highly recommend using ImageMagick instead of GD to resize and create thumbnail’s. You can do this by going to line #370 and setting $im equal to 1. Doing so should produce higher quality images, but they will also be bigger in size (not by a large margin). You can adjust the quality produced by changing “$funct[“resize”]($path,$full)” to be “$funct[“resize”]($path,$full, QUALITY)” where QUALITY is an integer from 1-100 and “$funct[“thumbnail”]($id,$thumbw,$thumbh)” to “$funct[“thumbnail”]($id,$thumbw,$thumbh, QUALITY”.

Article Request Count:

Archived [?]: replaced by <txp:zem_link href="310">mdp_automatic_randt</txp:zem_link> for RC3

Initially released:
Posted here:
24 Mar 2005

You know you want to visit the Archives.
Published with Textpattern