Setting A default image with PHPThumb

For one of the larger projects that I work on, I use phpThumb, which will create a thumbnail of the requested image and cache it for fast downloads. This is great when you have a large number of images that will be viewed at various sizes and you dont want to export all the various sizes.

One of the problems I ran into recently is setting a default image that will appear if for some reason your source file cannot be located. When you are pulling images from a separate provider, this can become a concern.

PhpThumb has made this easy as their is a setting in the config file as shown below.

phpthumbconfig

All you have to do is add the local path to the file you want as a default into the config and then to test it you can set phpThumb to attempt to load a bad source file and it should display your image. If you are having issues seeing the file, make sure that the names match up, and that you have a forward slash before the path. You can also try doing an absolute path with the entire url to the image.

Post to Twitter Tweet This Post

Leave a Reply