Using php thumbnail script in NewsArticles, PropertyAgent or Portal in general
host posted on August 21, 2010 05:32
The Ventrian way
Those of you that have build solutions using Ventrian NewsArticles or PropertyAgent are familiar with the thumbnail generation feature that is included and can be used by using [IMAGETHUMB]
This works great for most images if you need to only rescale an image and you always have the same aspect ratio ans shape (either rectangular or square). But if you want a square version of a rectangular image the thumbnail feature just dont work. the only option you have then is use the [IMAGETHUMBLINK] feature and also pass the width and height yourself, which will give the result you need but the image might look weird proportionally
<img src=''[IMAGETHUMBLINK:100:100]" width="100px" height="100px"/>
The TimThumb way
Fortunately there is a great .php script that handles this much better and creates good quality images even if your original image is rectangular shaped and you want a square thumbnail
Setting up the script
- Make sure your host supports php, I use PowerDNN myself and they supported this.
- Download the TimThumb script from darrenhoyt.com
- In the root of your server create a "php" directory and in the "php" directory create a "cache" directory and make sure both have write persmission.
- Now upload the timthumb.php script and you are good to go.
Using the script in Ventrian modules
<img src="/php/timthumb.php?src=[IMAGELINK]&h=150&w=150&zc=1" alt="" />
Using the script in your portal
<img src="/php/timthumb.php?src=/Portals/28/demo_unite.jpg&h=150&w=150&zc=1" alt="" />
TimThumb parameters
- w: width
- h: height
- zc: zoom crop (0 or 1)
- q: quality (default is 75 and max is 100)