Mailing List Archive

thumbnails on the fly
Hi,

I really need to switch to thumbnails. however I'll need several
thumbnails of different sizes. And I wish to avoid having many
documents of the same image unless they could be somehow be separated
from originals. So that they won't appear together in search results.

Since I don't know how to separate them, I was thinking about
creating thumbnails on the fly. A cover story template would do resizing
and cropping, and publishing the result, without ever storing a media.

Is this feasible?

Regards, Zdravko.
Re: thumbnails on the fly [ In reply to ]
On May 6, 2011, at 5:38 AM, Zdravko Balorda wrote:

> I really need to switch to thumbnails. however I'll need several
> thumbnails of different sizes. And I wish to avoid having many
> documents of the same image unless they could be somehow be separated
> from originals. So that they won't appear together in search results.
>
> Since I don't know how to separate them, I was thinking about
> creating thumbnails on the fly. A cover story template would do resizing
> and cropping, and publishing the result, without ever storing a media.
>
> Is this feasible?

No. Media have to be stored in the database in order to be published. Unless your template is going to replicate distribution, which I wouldn't recommend.

You can prevent thumbnails from showing up in search results if you make them of a type or in a category that your users don't have permission to see. If you're happy with that, then do check out find_or_create_alternate() in the Image class:

http://www.bricolagecms.org/docs/current/api/Bric::Biz::Asset::Business::Media::Image#Public-Instance-Methods

Best,

David
Re: thumbnails on the fly [ In reply to ]
On May 6, 2011, at 5:38 AM, Zdravko Balorda wrote:

> I really need to switch to thumbnails. however I'll need several
> thumbnails of different sizes. And I wish to avoid having many
> documents of the same image unless they could be somehow be separated
> from originals. So that they won't appear together in search results.
>
> Since I don't know how to separate them, I was thinking about
> creating thumbnails on the fly. A cover story template would do resizing
> and cropping, and publishing the result, without ever storing a media.
>
> Is this feasible?

No. Media have to be stored in the database in order to be published. Unless your template is going to replicate distribution, which I wouldn't recommend.

You can prevent thumbnails from showing up in search results if you make them of a type or in a category that your users don't have permission to see. If you're happy with that, then do check out find_or_create_alternate() in the Image class:

http://www.bricolagecms.org/docs/current/api/Bric::Biz::Asset::Business::Media::Image#Public-Instance-Methods

Best,

David
Re: thumbnails on the fly [ In reply to ]
David E. Wheeler wrote:
> On May 6, 2011, at 5:38 AM, Zdravko Balorda wrote:
>
>> I really need to switch to thumbnails. however I'll need several
>> thumbnails of different sizes. And I wish to avoid having many
>> documents of the same image unless they could be somehow be separated
>> from originals. So that they won't appear together in search results.
>>
>> Since I don't know how to separate them, I was thinking about
>> creating thumbnails on the fly. A cover story template would do resizing
>> and cropping, and publishing the result, without ever storing a media.
>>
>> Is this feasible?
>
> No. Media have to be stored in the database in order to be published. Unless your template is going to replicate distribution, which I wouldn't recommend.
>

Nor would I do that. :)

> You can prevent thumbnails from showing up in search results if you make them of a type or in a category that your users don't have permission to see.

This seems alright.

> If you're happy with that, then do check out find_or_create_alternate() in the Image class:
>
> http://www.bricolagecms.org/docs/current/api/Bric::Biz::Asset::Business::Media::Image#Public-Instance-Methods
>

Thanks.
One more thing, though: does this API allows for more than one thumbnail?
How to keep up with changes of the original media document? I saw somewhere, it's been
solved, but can't find it.

Zdravko
Re: thumbnails on the fly [ In reply to ]
On May 9, 2011, at 12:24 AM, Zdravko Balorda wrote:

> Thanks.
> One more thing, though: does this API allows for more than one thumbnail?

Yes, just specify a different file_prefix or file_suffix for each.

> How to keep up with changes of the original media document? I saw somewhere, it's been
> solved, but can't find it.

It does not track changes in the original media document. Your template could sniff at the original and the thumbnail, though, and decide if it needs to be regenerated. Maybe the mtime on the files?

Best,

David
Re: thumbnails on the fly [ In reply to ]
>> You can prevent thumbnails from showing up in search results if you
>> make them of a type or in a category that your users don't have
>> permission to see.
>
> This seems alright.
>

It just has hit me: would a user be able to publish thumbnails in this case?

Zdravko
Re: thumbnails on the fly [ In reply to ]
On May 22, 2011, at 11:37 PM, Zdravko Balorda wrote:

>>> You can prevent thumbnails from showing up in search results if you make them of a type or in a category that your users don't have permission to see.
>> This seems alright.
>
> It just has hit me: would a user be able to publish thumbnails in this case?

Yes, if they're related, IIRC. TIAS.

Best,

David
Re: thumbnails on the fly [ In reply to ]
David E. Wheeler wrote:
> On May 22, 2011, at 11:37 PM, Zdravko Balorda wrote:
>
>>>> You can prevent thumbnails from showing up in search results if you make them of a type or in a category that your users don't have permission to see.
>>> This seems alright.
>> It just has hit me: would a user be able to publish thumbnails in this case?
>
> Yes, if they're related, IIRC. TIAS.
>

Still, template will need to create media of a type for which a user will not
have even a READ privilege?!

There is a great thing about Bricolage being static: thumbnails can be created
by templates, and need not to be created in advance, typically before one even
knows the size of the thumbnail. Drupal can eat itself. :)

Regards, Zdravko
Re: thumbnails on the fly [ In reply to ]
On May 23, 2011, at 10:49 PM, Zdravko Balorda wrote:

> Still, template will need to create media of a type for which a user will not
> have even a READ privilege?!

Templates don't check permissions, so you're fine there.

> There is a great thing about Bricolage being static: thumbnails can be created
> by templates, and need not to be created in advance, typically before one even
> knows the size of the thumbnail. Drupal can eat itself. :)

Yep.

Best,

David