Image Management Tools

Get PThumb to Follow Server Symlinks

light fare

PThumb and Server Symlinks

PThumb works fine when the path to the image is straighforward. But images can be stored in any number of places. This tip comes from a post to the Slack #development channel.

optimuscrime asked...

Does anyone have some experience with pthumb/phpthumbof and symlinked directories? It does not manage to translate the paths correctly

The Solution:

optimuscrime says...

...simply setting 'phpthumb_allow_src_above_docroot' to true worked for me.

What's the Story?

You shall not pass!

Image (and other) files are often stored above the web root to protect them from casual access. In some cases, the server is configured to allow PHP to access files outside of the web root. In cases where it is not permitted, one solution is to create a symlink in the server's filesystem, creating a virtual directory in the web root that directs to the actual directory.

The issue here wasn't so much that pThumb couldn't follow the symlink, it was that the phpThumb library (which pThumb uses) itself has its own settings to control where it can go to get files. In this case, changing the Sysem Setting 'phpthumb_allow_src_above_docroot' to 'true' to allow it to look in directories outside of the web root solved the problem.