If you'd like to provide updated information and do not have access to directly edit, please contact the site admin; thanks!
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!
- Download mdp_automatic_randt
- Rename /textpattern/include/txp_image.php to txp_image.original
- Put “mdp_automatic_randt.v0.5.1.txt” into /textpattern/include/
- Rename “mdp_automatic_randt.v0.5.1.txt” to “txp_image.php”
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”.