Closed (fixed)
Project:
ImageCache
Version:
6.x-2.0-beta10
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
28 Feb 2010 at 15:27 UTC
Updated:
2 Jun 2012 at 22:25 UTC
Hello,
I have a cck image with display : presset image linked to image
I copied function theme_imagecache_formatter_imagelink($element) in my themes folder and rename it basic_imagecache_formatter_imagelink($element).
I added attribut target = _blank, in the good way to open image in a new window.
It's not working.
It works if I hack directly imagecache module, same function.
Why does not it work in my theme?
I must add I did same for filefield and it worked.
Comments
Comment #1
sahuni commentedComment #2
sahuni commentedWwhen I click on presset, the bigger size image must open in a new window.
Is it OK to use theme_imagecache_formatter_imagelink in my template.php ?
It's not theme_filefield_file?
My new fuction in template.php is the following (I added ",target=> _blank" in last line)
Can you tell me why it does not work?
Comment #3
sahuni commentedI don't really understand because devel themer info gives theme_imagecache() function, but sensible code is in function theme_imagecache_formatter_imagelink.
At what level must I change something?
Comment #4
sahuni commentedIn fact, I needed to add presset in my function name
Comment #5
babbage commentedI am having the identical problem, but have not solved it yet. Can you please explain exactly what you did to solve it? Normally, in a function like this I would replace the word "theme" with the name of my theme. Did you do this? Do you also have to put the name of your imagecache preset in the function name as well? If so, where exactly do you put it? I have tried multiple ways to combine these but it is not working... like you, changing the original function does exactly what I want so I know it isn't the code that is bad.
Comment #6
babbage commentedOK. Have figured this out. For any other poor soul who treads this same path, here is how you have to name the function:
MYTHEMNAME_imagecache_formatter_MYPRESETNAME_imagelink()
Personally a) this doesn't seem very obvious and b) it doesn't seem to be documented anywhere. Would be nice if it was. I'll try and travel back these ways and do that sometime in a more formal way.
Incidentally, it would appear this will not work if you use underscores in your preset names, and I suspect hyphens may be a problem as well although I haven't tested that and would be pleased to be wrong there.
Comment #7
alisonI agree with most of what's been said here. HOWEVER... in the meantime, I thought I'd share what I've come up with -- using this discussion and others -- in case it's helpful for anyone.
A little context: I have an image nodetype (using imagefield/filefield, not Image module) and I've created a View that uses the Lightbox2 trigger field thing so that I can have a gallery of thumbnails that link to large versions of the photos, with the images' titles, captions, etc. underneath (in the lightbox), along with the "next/previous/etc" lightbox functionality.
I wanted users to just have to enter a node title, an image file, and caption text for each image node. For uninteresting reasons, I ended up using the "title" field (part of the imagefield's "data") for the caption text.
Bottom line -- I wanted to use the node Title for the alt-text and "title" attributes of the images when they were displayed in the gallery (thumbnail and large versions). So, this is what I added to my template.php:
(And then again for my large-size preset.)
Anyway, like I said, hopefully this is helpful for someone! Let me know if I can provide any additional info/details.
Comment #8
fizk commentedPlease reopen if this is still an issue with ImageCache 6.x-2.0-rc1.