Closed (fixed)
Project:
ImageCache
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
7 Dec 2006 at 15:40 UTC
Updated:
6 Apr 2007 at 14:39 UTC
Jump to comment: Most recent file
Comments
Comment #1
quicksketchI totally agree with this proposition. Theming the output no matter where it came from would be a useful tool. Additionally, adding the anchor tag to the image source might be useful but should not be the default behavior.
In the patch above, I've extended the formatting options for imagefield in views. Now there are two options when using an imagecache preset: the existing option plus a new 'as link' option. The second option makes it possible to link directly to the parent node which contains the imagefield. This option is essential if you were building an image gallery out of views, imagefield, and imagecache for a list of thumbnails linked to full nodes.
I also rearranged the order and number of arguments passed to the theme function to match all the information passed into hook_field_formatter().
Comment #2
dopry commentedI want to hold off on this for a bit. There is a patch pending for content module that will change how formatters are handled. I want to wait to see if it goes into the 1.x branch or the 2.x branch and if it goes into 4.7 or 5.0 before strongly reviewing this patch.
http://drupal.org/project/comments/add/107128
Comment #3
schwa commentedRobert/Quicksketch, I'd dearly love the functionality of this. Patched HEAD with Quicksketch's version, installed it on a 4.7.4 site, but got
Fatal error: Call to undefined function: module_exists() in /home/apache/htdocs/xxx/sites/xxx/modules/imagefield/imagefield.module on line 154
Is this patch of HEAD usable for 4.7.4? Thanks!
Comment #4
quicksketchThat's a small difference between 4.7 and 5. Just change 'module_exists' to 'module_exist' and things should be fine.
Comment #5
karens commented+1 on this idea. I need it, too. @dopry, my request is just to add a formatter that has this behavior so it shows up as an option in views and is available for themes. I don't *think* the proposed changes in the content module would have any effect on adding a new formatter -- they just give you more ways to use whatever formatters you have. I may be missing some implication of the changes, though, so obviously it's up to you :-)
Comment #6
karens commentedOK, now that I think about it, you are probably talking about the proposed changes in the way fields are themed. Hmm... I guess I'd better go spend some time on that issue so we can get this one unstuck :-)
Comment #7
quicksketchThe awesome teaser/body patch went in for CCK (http://drupal.org/node/107128). Great work dopry on the integration needed in imagefield. Here's an updated patch to apply to the DRUPAL-5 branch. The above patch still works on 4.7 without changes. Let me know if any changes are needed.
Comment #8
dopry commentedI'm still kind of mulling this over. It would be nice if we had some sort of formatter options like widgets. Why not just put all of the imagefield formatter into the theme function to allow easy overrides or write your own custom formatter? Are there any opinions for wrapper vs theme_imagefield_formatter vs custom formatter?
Comment #9
quicksketchHmm, formatters provided by a theme function? Does this mean that hook_field_formatter_info() and hook_field_formatter() would both call theme functions so they could create unlimited options?
I think what we're looking at here is a design decision in CCK to have a set number of formatters within a single field module. It wouldn't be difficult to create a module which could provide unlimited custom formatters for every field type, but I don't think it's something that should be implemented in a field module directly.
Alternatively, if someone wanted to create just one additional formatter for imagefield, a custom module would be the way to go (though I doubt many users would realize this). It would just need to implement the two hooks mentioned above and contain a theme function to control the output.
Comment #10
karens commentedI agree it would be nice to refactor the way that CCK does this so there is more flexibility in the formatters that can be made available. I also agree that doing that is something that probably doesn't belong here, in the field, but in the content module.
Themes are the most versitile way to do this, the downside is that there is no way to control formatting from a web browser, since that's the big CCK pitch -- you can do everything from a browser.
Anyway, maybe use a theme as an interim solution, then put some thought into what the CCK overall solution for custom formatters could/should look like.
Comment #11
quicksketchI also want to put this patch on hold.
In the thickbox patch discussion yched pointed out that content formatters can be stored in any module and yojoe asked why imagecache formatters weren't in the imagecache module.
I believe that the imagecache formatters in fact should be stored in imagecache. That makes more sense to me. Then this patch can be rewritten so instead having an ugly _wrapper() function, we'd make a theme function, theme_imagecache_formatter($field, $item, $formatter), which handles display of various formatters provided by imagecache. What do you guys think?
Comment #12
dopry commentedSounds like the ticket, do you have time to work on it, or should I pump it out over the weekend?
Comment #13
dopry commentedSounds like the ticket, do you have time to work on it, or should I pump it out over the weekend?
Comment #14
quicksketchI've still got this on the back-burner. I hope to get to it soon.
Comment #15
quicksketchAs we discussed before, imagecache should provide it's own field_formatters for CCK, which then will affect the available options for imagefield, rather than imagefield including calls to private functions in imagecache and using "if module_exists()" all over the place.
Attached is a patch which moves the formatter code from imagefield into imagecache.
It also adds the "as link" formatter so thumbnailed images can link to the main node.
In my testing, it seems like this patch does NOT conflict with the existing version of imagefield (5.x branch). Meaning that even though imagefield and imagecache are both providing formatters, they work the same as before. Once the code is removed from imagefield, no database updates or similar will be necessary: the upgrade was flawless.
Note that a new imagecache preset must be created/updated or the cache reset using devel module to show the new "as link" formatters.
I'll link to the related imagefield patch shortly.
Comment #16
quicksketchRemove imagecache code from imagefield:
http://drupal.org/node/123340
Comment #17
quicksketchCommitted to 4.7.x, 5.x, 5--2 branches. Woohoo!
Comment #18
(not verified) commentedComment #19
mgrant commentedI applied imagecache_add_formatters.patch to imagecache.module but I don't see any new "formatters" in image cache. By "formatter", do you mean where it says "Add a New Action"? All I have still is Scale, Resize and Crop. How would I add a link to an image with this?
I'm using drupal 5.1 with imagecache from Feb 21 which appears to be the latest. The patch took without errors.
Comment #20
mgrant commentedAhh, wait, I think I see. I also patched imagefield with imagefield_formatter5.patch. Now, I see in the field in the view there's an "as link" version of my image cache preset. After selecting that, now when I click on the image, it brings me to the node view. Ok, good start!
What if wanted to specify the link myself, for example a link to another website? Or what if I wanted to specify it by a reference (within my drupal site) using a cck reference so the content creator can choose where the link on this photo points?