Here's a patch for the head version as of 5/31/07 that adds optional link support to imagefields. Link capability can be turned on or off like custom title and custom alt. Also allows optional link target like _blank or _self.

Tested with vanilla imagefields, but I'm not sure how this integrates with imagecache. The sponsoring site doesn't use it, so I haven't had the opportunity to test that combo.

Requires a schema update with update.php to add the url and target fields.

Hopefully someone finds this useful.

Comments

dopry’s picture

Status: Needs review » Needs work

This looks like a really cool addition, but I would appreciate it if you could reroll the patch again against the DRUPAL-5--2 branch. There are a lot of changes in that patch.. It almost seems diffed against an earlier 5.x branch which is probably my fault for not keeping head up to date. After the 5.x-2.x branch is released I'll sync head up and continue future development there.

criznach’s picture

Let me see what I can do... It's working for us now, so the pressure is off. I'm also looking at adding a weight field to the attached images. Any thoughts positive or negative on that?

jnorton’s picture

Hello,

Is there any update on this patch being available for the 5.2 version of image field?

Thanks,

Justin

philsward’s picture

I am looking right now for a way to do exactly that! I would love the ability to weight attachments of the images :)

I am playing with the Imagefield Gallery at the moment and while the base functionality is there to setup a nice and easy little gallery, it still lacks the ability to move images.

The only way I know of to do this is delete the images and start over. That's fine if I am the one doing it, but clients will complain which is the ultimate purpose of the gallery...

I don't know what your thoughts or knowledge are on ajax, but It would be "nice" if the weighting were ajax drag & drop based. I.E. Drag the image to the spot where it needs to be displayed, when attaching the images.

If I knew php and ajax, I would help... otherwise the suggestion, though a bit late on the response, would sure be appreciated!

philsward’s picture

I am looking right now for a way to do exactly that! I would love the ability to weight attachments of the images :)

I am playing with the Imagefield Gallery at the moment and while the base functionality is there to setup a nice and easy little gallery, it still lacks the ability to move images.

The only way I know of to do this is delete the images and start over. That's fine if I am the one doing it, but clients will complain which is the ultimate purpose of the gallery...

I don't know what your thoughts or knowledge are on ajax, but It would be "nice" if the weighting were ajax drag & drop based. I.E. Drag the image to the spot where it needs to be displayed, when attaching the images.

If I knew php and ajax, I would help... otherwise the suggestion, though a bit late on the response, would sure be appreciated!

philsward’s picture

I think my browser hung when I posted the previous comment, so it posted it twice... This is just an edit to remove the 'second' posting since I can't physically delete it.

jpetso’s picture

Title: Optional link for imagefields » Arbitrary link for images

Marking #171280: Arbitrary link from image as duplicate of this issue, and stealing its name - I think it can more easily be distinguished in between all those other "link" feature requests.

Fayna’s picture

Has this patch been committed to ImageField now or does it still need work? Among the many 'links' issues I'm glad I found this one! :P

Henrik Opel’s picture

Category: task » feature

Changed to feature request.

I'm looking for exactly this functionality and might be willing to adjust/rework the patch to work with the current version.

Since this topic/request/patch is rather old, it would be nice to have some confirmation that this is still a wanted contribution for the ImageField module and not addressed already somewhere else, though.

vojnar’s picture

Category: feature » bug
Priority: Normal » Critical

Hello,

This is what I get running the patch:

/modules/imagefield# patch < imagefield_4.patch
patching file imagefield.install
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 49.
Hunk #3 succeeded at 108 (offset 13 lines).
2 out of 3 hunks FAILED -- saving rejects to file imagefield.install.rej
patching file imagefield.module
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 75.
Hunk #3 FAILED at 94.
Hunk #4 FAILED at 147.
Hunk #5 FAILED at 162.
Hunk #6 FAILED at 178.
Hunk #7 FAILED at 197.
Hunk #8 FAILED at 216.
Hunk #9 FAILED at 230.
Hunk #10 FAILED at 307.
Hunk #11 FAILED at 332.
Hunk #12 FAILED at 488.
Hunk #13 FAILED at 525.
Hunk #14 FAILED at 563.
Hunk #15 FAILED at 571.
Hunk #16 FAILED at 612.
Hunk #17 FAILED at 623.
Hunk #18 FAILED at 655.
Hunk #19 succeeded at 421 with fuzz 2 (offset -318 lines).
18 out of 19 hunks FAILED -- saving rejects to file imagefield.module.rej

Any idea what should be done? Am I doing something wrong?

Best regards,
Gabor

jpetso’s picture

Category: bug » feature
Priority: Critical » Normal

@vojnar:
Judging by the output, I can only assume that you patched against a different version than the patch was taken from. That's not a good reason to change the perfectly sensible issue status, though.

@HeO:
It's not addressed in imagefield at least, but I don't know how open the maintainers are for inclusion of this patch. (Might be worth a try, but I can't really tell.)

attiks’s picture

Hi,

Looked at your patch and kind of like the idea, but please don't use target, it isn't valid xhtml :/ You'll need to use jQuery magic to deal with it :p

Edit: What i mean is don't output the target attribute, but use something like class="target_blank" instead, using jQuery we can do this

  $("a.target_blank").click(function(){
      window.open(this.href,'external');
      return false;
  });
vojnar’s picture

Category: feature » bug

This is the response from the server on the correct imagfield module (6.x-3.x-dev) on a brand new install of D6

patch
patching file imagefield.install
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 49.
Hunk #3 succeeded at 108 (offset 13 lines).
2 out of 3 hunks FAILED -- saving rejects to file imagefield.install.rej
patching file imagefield.module
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 75.
Hunk #3 FAILED at 94.
Hunk #4 FAILED at 147.
Hunk #5 FAILED at 162.
Hunk #6 FAILED at 178.
Hunk #7 FAILED at 197.
Hunk #8 FAILED at 216.
Hunk #9 FAILED at 230.
Hunk #10 FAILED at 307.
Hunk #11 FAILED at 332.
Hunk #12 FAILED at 488.
Hunk #13 FAILED at 525.
Hunk #14 FAILED at 563.
Hunk #15 FAILED at 571.
Hunk #16 FAILED at 612.
Hunk #17 FAILED at 623.
Hunk #18 FAILED at 655.
Hunk #19 succeeded at 421 with fuzz 2 (offset -318 lines).
18 out of 19 hunks FAILED -- saving rejects to file imagefield.module.rej

jpetso’s picture

Category: bug » feature

vojnar: The patch might not apply for you, but this issue is still a feature request for imagefield. Please leave it at that until this functionality is added to the upstream version.

dragonwize’s picture

subscribing

mroswell’s picture

Much-needed, even after two years.

Check out http://drupal.org/project/linkimagefield and http://drupal.org/node/343177 for related efforts, also not yet available for D6.

dragonwize’s picture

Assigned: Unassigned » dragonwize
Status: Needs work » Needs review
StatusFileSize
new5.5 KB

I've needed this for a few things in the past couple months but have always had something more important to do. Well, now here is a patch and I am dedicated to seeing this through.

This is a call for reviewers. Please put this patch through some good testing.

We will need to follow this one up with a nice patch to imagecache once this gets committed.

drewish’s picture

i'm really not sure that this is something that imagefield should be doing.

dragonwize’s picture

@drewish

I am open to better suggestions that fix the use cases better.

quicksketch’s picture

I agree, I'm also not sure this should be part of ImageField. Upload an image... and add a link to any random URL? In the case of single-value fields, this doesn't add much value at all, since you could easily add a separate field for URL then theme them together. For multivalue fields, we should just wait for #119102: Combo field - group different fields into one.

If you really, really want to do this in ImageField, I'd suggest making a new widget for FileField that extends ImageField, similar to how ImageField Crop module is "Image with croppping" you could make a new widget for "Image with URL".

mroswell’s picture

Uploading an image, and adding a link to a random URL is truly a desperately needed functionality in Drupal.

Quicksketch, and drewish, you're coming from the perspective of an expert. But the random person just needs to be able to link an image to a random URL, and struggles with theming. "Easily add a separate field for URL then theme them together" or "make a new widget" just isn't something your average end user can do.... or rather, not something that the end user knows how to do. Maybe it's something they might easily do if someone told them how, step-by-step... and if they remember their host information, and know how to navigate the command line, etc.... Best to add to an admin interface. (Whether filefield widget, or imagefield, I don't have a point of view.)

Here's one use case for now: http://www.BaltimoreUrbanAg.org. The image in the left sidebar block (a mini of an utterly gorgeous poster for our Urban Agriculture Gala) should link to a full node... but not its own node. But there are three million other use cases for linking an image to a random URL, either internal or external to the site.

I look forward to testing the patch, which I'll have a chance to do this weekend!

attiks’s picture

I have to agree with drewish and quicksketch, if they have to add fields for every use case the module will become bloated, have a look at the new combo field and rather try to test that patch, once in all possible use cases are possible without any module become bloated. I agree that a clean and clear documentation will be needed for the combo field so any user will see the benefits and easy of use.

I solved it by using a different node type for the images and I used an embedded to view to display/theme them all together. It's a bit more work for the end user (create a new node for each image), but the advantage is I'm able to add any extra information I wanted.

mroswell’s picture

dragonwize: I'm using Acquia Drupal, and got this when I tried to apply the patch.
(Is 6.x-3.0-beta3 release the same as HEAD? Is that the one to try?)

(Stripping trailing CRs from patch.)
patching file imagefield.module
Hunk #1 succeeded at 120 with fuzz 2 (offset 40 lines).
Hunk #2 succeeded at 223 (offset -6 lines).
(Stripping trailing CRs from patch.)
patching file imagefield_formatter.inc
Hunk #1 FAILED at 91.
1 out of 1 hunk FAILED -- saving rejects to file imagefield_formatter.inc.rej
(Stripping trailing CRs from patch.)
patching file imagefield_widget.inc
Hunk #1 succeeded at 95 (offset 3 lines).
Hunk #2 FAILED at 145.
Hunk #3 FAILED at 156.
Hunk #4 FAILED at 214.
3 out of 4 hunks FAILED -- saving rejects to file imagefield_widget.inc.rej

dragonwize’s picture

Assigned: dragonwize » Unassigned
Status: Needs review » Closed (won't fix)

mroswell: No, 6.x-3.0-beta3 is not the same as HEAD.

However, it looks like this issue has been shot down. Which I am fine with, just wish it was done so before I wasted my time on this issue.

@quicksketch: I realize you have just taken over this module and have your hands full. I love the work you have done so far but can you please mark issues appropriately if they don't fit in your plan so that others that want to help do not waste their time. Thanks.

mroswell’s picture

Just a quick vote here from one soul: Would be GREAT to have this much-needed functionality. Although I didn't quite manage to make the test environment to make dragonwize's patch work, seems we're soooo close, that we might as well get it done. (Does that logic work?)

If this direction is not approved (confirmed "won't fix" from the module maintainer), would be great if someone who says there's an easy alternative could write up a handbook page describing how, and add a link here.

aliciatheduff’s picture

I second #26. I would love this functionality.

perandre’s picture

There's an effort going on here: http://drupal.org/node/343177