Closed (won't fix)
Project:
Link
Version:
4.7.x-1.4
Component:
User interface
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
5 Mar 2007 at 12:50 UTC
Updated:
30 Jul 2007 at 20:02 UTC
Is it possible to use an image as the clickable anchor of a URL?
Comments
Comment #1
quicksketchNot right out of the box. You should look at contemplate module, which let's you create templates per content-type and cck field.
Comment #2
joel_guesclin commentedWill this work in Views (ie a View list of CCK items), or only in a display of the CCK item itself?
Comment #3
quicksketchIt works in both. They both use the the same method of display, running through the link_formatter() then through a theme function, which is where contemplate comes in.
Comment #4
vangelisp commentedI find it extremely difficult to use contemplate in order to output a nice icon instead of the default title. Whenever I try to modify the template, I always brake something.
Yes I know, I might be retarded or something, but it should be really really nice if we had an optional image instead of title (then the title would go to the "alt" tag..). It would make things alot easier!
What do you think?
PS. I'm using Drupal 5.
Comment #5
phnad@drupalcenter.de commentedwould love to get this function,
i need it, too.
Comment #6
quicksketchI'm afraid I simply must deny this request. Even if a patch were submitted I would not commit it. The complexities of pulling files from URLs or file uploads is far beyond the scope of this module. The better approach might be to make a separate module which provides the necessary widget for CCK, combining the abilities of link.module and imagefield.module. But as for implementing the entire functionality in this module, I do not think this module is suited to accomplish the task.
As I said above, this can be accomplished with contemplate or some basic theming, depending on your purpose.
Comment #7
vangelisp commentedWell, I had to give this kind of result to my website, so I've started modificating the module.
Unfortunately, for those who are going to do it, be aware that I'm also modifying the common.inc along with the link.module ,to make it work my way. I'm sure I'm opening a probable security hole here, but for the sake of appearance, I had to do it.
Okay, actually, this kind of mod is not exactly a universal one.
What I'm doing is to put a specific title to the link and then give the url.
If the title fits on a specific category of acceptable titles (which I've hard coded into the module), it adds a .gif or .jpg extension and shows it to the screen.
Lets go to the module itself. On line 398 of link.module. You should see:
Now, I've commented the whole thing,since I didn't wanted to ruin it in case something went wrong, and added this one exactly below:
So, I say to the module: If you find the title "photos" or "geomap", it's a graphic link, so utilize the variable $imgicon with the path to the icon I want to use. The variable then passes through the l2 function (which I'm going to comment below) to the common.inc module, in order to create the link with the url and icon.
Now, on the includes/common.inc , line 1264, you see the official function 'l', which is the function that creates the link.On line 1275 it finished. Then I'm pasting my newly made function, named 'l2':
And for those that care to see the results, here's an example:
www.motoridersclub.com/en/node/477
In the above example, the map link is created by giving the title to the link 'geomap' and the photo link icon at the bottom is created by giving the title to the link 'photos'.
Again, since I'm alterning the common.inc, it's NOT considered a safe modification.Do it on your own risk fellas!
Any ideas would be great!