by
KK » Tue Dec 24, 2013 7:04 am
OK, I admit friends, the documentation on securefile is rather scant at this point.
I'll try and put down all the pertinent info about it here (including how it deals with thumbnails).
As you know, securefile can be used to upload both files as well as images.
So, in a sense, it is a combo of the regular 'file' and 'image' type editable regions.
Optionally, we can also configure it to create thumbnails for uploaded images (which is what you are interested in). So, now it actually
becomes a combo of file, image and thumbnail type editable regions rolled into one.So, the securefile region actually supports a whole lot of parameters that are common to the regular regions it acts as.
Depending on whether the uploaded entity is a file or an image, the relevant parameters come into play.
Let us take a look at the parameters that can be used to handle uploaded images.
When the uploaded entity is an image, all the usual parameters of the regular 'image' editable region come into effect.
Namely -
* width
* height
* enforce_max
* crop
* quality
* show_preview
* preview_width
* preview_height
You can take a look at the docs for 'image' type for details - (
http://www.couchcms.com/docs/tags-refer ... image.html).
And now the info you were looking for:
To make securefile also act as a thumbnail region, we have to set at least one of the following two parameters -
* thumb_width
* thumb_height
Those are the parameters that signal securefile to create the thumbnail.
Following parameters can be used to exert finer control over the thumbnail created
* thumb_enforce_max
* thumb_quality
Additionally, if we have set the 'show_preview' parameter mentioned above, we can make securefile use the thumbnail (instead of the main image) to show in the preview. Following parameter does it -
* use_thumb_for_preview
As an example of usage of the parameters, we'll use the original definition of Rafael
- Code: Select all
<cms:editable
name='imagefile'
allowed_ext='png, jpg, jpeg'
max_size='2048'
type='securefile'
/>
We'll modify it as follows to make securefile create a thumbnail of width 100px and also show it as preview -
- Code: Select all
<cms:editable
name='imagefile'
allowed_ext='png, jpg, jpeg'
max_size='2048'
type='securefile'
thumb_width='100'
show_preview='1'
use_thumb_for_preview='1'
/>
Hope this helps.
Do let us know.