phpThumb Integration -- Need some advice

Permalink
In the interest of making things as easy as possible for the end user of the site I'm hoping to implement phpThumb (http://phpthumb.sourceforge.net/) into c5 mainly to apply a mask to images to put a border on them. I know picnik has some framing options but not what I'm needing. (besides picnik is crashing for my install)

I've accomplished integration so far by simple adding a function, frame, to the download_file.php controller. I'm using the download_file.php controller because this is what the file chooser passes to tinyMCE when you choose an image. So then tweaking the URL a bit I get what I want.

For example the URL /index.php/download_file/-/frame/7|brush_06|180 would put the 'brush_06' frame on the image and size it down to 180 pixels width. The frame function parses the url and passes it off to phpThumb which outputs the image. It all works great but I'm still hoping to make it even easier for the end user.

I've been searching around for other possible points for integration and came across 'Files Attributes' in the file manager. I don't have a very clear understanding of the file helper or however all this works but:

Is there a way to access these attributes from like the download_file.php controller?

If so then perhaps a better way to integrate this would be for them to specify the attributes from the dashboard rather than tacking them onto the URL from tinyMCE?

or... Maybe I need to hack up tinyMCE instead to generate the URL easier?

I also thought of making a block or something but then I wouldn't be able to use images inline with the content. (float left, etc)

I'm really open to suggestions and advice from some of the more experienced users of c5's inner workings. I might be taking the complete wrong approach.

Thanks!

=D

2 Attachments

 
Graphikos replied on at Permalink Reply
Did my thread get lost somehow? I couldn't find it on the forums. Bump.
Remo replied on at Permalink Reply
Remo
Your thread is still there and I already saw it, but honestly I don't know the best way to solve your problem..

I've seen that c5.3 sometimes loads pictures using download_file. If it would load all the pictures using download_file it would be very easy to do. Add some file attributes and check them in downoad_file - done!

But as already someone mentioned, it's not always a good idea to load pictures using this script. It might work better if there was some kind of cache management (not talking about the cache library which has been around since 5.2). Adding expires tags and similar stuff is someting essential.

---

Yes, download_file would work but I'm avoiding download_file at the moment whenever I can...

Maybe we should first "fix" the download_file headers problem.
Remo replied on at Permalink Reply
Remo
this is the discussion I meant:
http://www.concrete5.org/community/forums/usage/concrete_5_3_no-cac...

He also tries to get rid of download_file...
Graphikos replied on at Permalink Reply
Odd.. I searched several times through the first 6-7 pages of the forum and couldn't find it. Finally found it with search. Anyhoo..

Thanks Remo for the input. I know that phpThumb has a decent caching system and I use it heavily on other non-c5 sites so I'm not too concerned about that.

Can you give me some help on how you pull those attributes? I can't find any examples or documentation on it.

=D
Remo replied on at Permalink Reply
Remo
phpThumb cache is not what I'm talking about.

I'm talking about the browser cache and how you can influence it using some fancy headers.

If you load something like thishttp://server/background.jpg it gets cached by the browser, but if you do thishttp://server/download_file.php/background.jpg... it doesn't unless you carefully set some headers..
Remo replied on at Permalink Reply
Remo
I never tried but by looking at the code I guess something like this should work

1. get file object (File::getById...
2. get file version object ($file->getVersion..
3. get attribute $fileVersion->getAttribute

but you might want to check the code on your own for this..
weltenschmid replied on at Permalink Reply
weltenschmid
Perfect, just what I sought to fix your tenant directory block for the IE brood. :-p
resahc replied on at Permalink Reply
Remo - Can you please give us more details with that header setting issue? IE doesn't cache the phpthumb generated images. We tried more than a week to solve this issue.
Thanks
Remo replied on at Permalink Reply
Remo
There isn't a single simple answer to that question/problem

1. Does the url change?
2. How does phpThumb get called? mod_rewrite?
3. What does FireBug tell you about the headers?

...
resahc replied on at Permalink Reply
You can see an example here:
http://caribbeanfuse.com/beta.php...

the url is something like this :http://caribbeanfuse.com/360x220_img_resnl/juice/pics/50_364325083....

phpthumb is called via a 404 error handler.

in mozilla firefox is working fine...just in IE I have problems
Remo replied on at Permalink Reply
Remo
I doubt that using a 404 handler is the right way to do this...

I never read anything about 404 & caching because caching a 404 page isn't important. It should never happen.

Can't help you with that but I suggest trying a real rewrite. In my case, the cache also doesn't work with Firefox... It looks like it reloads all the pictures an gets a 404 for almost every file. Everything is red in firebug...
resahc replied on at Permalink Reply
I'm not really that good at .htaccess rewrites that's why I chose to do a 404 error handler.
Can you help me do a rewrite rule to the url I gave as an example?

Thanks a lot for everything
Graphikos replied on at Permalink Reply
http://mrphp.com.au/code/project/miscellaneous/image-cache-using-phpthumb-and-htaccess

=D
Remo replied on at Permalink Reply
Remo
this isn't that easy..

that redirect is a bit silly as it redirects everything to that php script. It has some basic 404 error handling functions but that's probably not enough in a lot of situations..

Also c5 uses a similar rewrite meaning that you can't use it, otherwise c5 won't work..

You have to modify the script and the rewrite in order to use it!
michaelfillier replied on at Permalink Reply
michaelfillier
Maybe taking a look into Drupal's imagecache module would be a good option: drupal.org/project/imagecache

The module lets you define profiles and call them via a theme function or other modules. Presets can contain scaling, cropping, and once the image is processed it is cached. This is great when you want to use the image in multiple locations.
jordanlev replied on at Permalink Reply
jordanlev
FYI -- Concrete5 automatically caches images. You don't need to declare profiles or anything either -- as long as you're using the image helper, it will automatically use a cached version of any file it has previously processed (e.g. converted to a thumbnail of a particular size).

It doesn't include cropping, but myself and others in the community have created an improved helper that does offer this as well (and it will do the caching just the same):
http://www.concrete5.org/community/forums/customizing_c5/getthumbna...

Cheers,
Jordan