integrates phpthumb into userfrosting v0.3.1+
Thanks to phpthumb we can create thumbnails with a powerful suite of options.
This plugin has had little to no testing by third parties or in live environments. If you choose to use this plugin in its preliminary stages you may run security risks. I have taken the precaution of requiring a hash when requesting an image, so nobody can externally tell the server to generate thumbnails of all shapes and sizes.
- Create a folder in your userfrosting's "plugins" folder and name it "UserFrostingPlugin-phpThumb"
- Drop the contents of this project into the newly created folder
- Within UserFrostingPlugin-phpThumb, open config-plugin.php
- The only thing you MUST configure is the 'high_security_password'. Use something long and complex or php will log an error and not render any images.
- Once configured, navigate to http://(your domain or public folder)/phpthumbtest to test and preview
- Thumbnails are generated on-demand unless a cached version exists on the server.
- To insert a thumbnail into a twig template simply use the
pthumb
function.
pthumb( name of slim route
, subfolder within imageFolder
, source image filename
, phpthumb parameters
)
name of slim route
: as defined in the config. Built-in routes include "user-image", "public-image", and "my-image". Define your own for more customization.subfolder within imageFolder
an optional parameter unless requesting a "user-image", in which case you use the user ID of the image's ownersource image filename
: need I say more?phpthumb paramters
: refer to the phpThumb readme. NOTE: filters are handled differently. Instead of "fltr[]=" use "fltr1=","fltr2=", and so on for multiple filters
The following will display the image "stuck.jpg" from the publicly viewable folder using only the default phpthumb parameters.
<img class="thumbnail" src="{{site.uri.public}}{{ pthumb("public-image","","stuck.jpg","") }}">
this is what you should see when you load /phpthumbtest
- This is not a file manager by any means. If you choose to utilize the option "usersHaveSubdirectories" it will be up to you to figure out how those files will get there. Be sure to take safety precautions in handling file uploads, especially if you don't personally know your users.
- Test test test....
- Automatic cache cleanup