8

I need to get an image's full URL path as a token that I can use as a replacement pattern in Views.

I'm trying to have one thumbnail image link to a larger image. I have the larger image excluded from view so I can use it as a token. When I try to export the thumbnail image as a link using the larger image's token, the token is apparently the <img> tag instead of the path.

I think I can do this if I change the field type of the larger image to a File, but I want the benefits that come with the Image type (cropping, scaling, etc).

3 Answers 3

7

I ended up using a module to create a custom formatter. Image URL Formatter http://drupal.org/project/image_url_formatter . It created a new formatter option called "Image URL," and I can use that as a token.

4

Old, but I think:

[node:IMAGEFIELD_TOKEN:file:url]

would do it

of in case of a multiple image field:

[node:IMAGEFIELD_TOKEN:IMAGEFIELD_IDX:file:url]

Where

  • IMAGEFIELD_TOKEN is your image field token, like field-image, field-images, etc.
  • IMAGEFIELD_IDX (for multiple fields) is your 0-based index. 0 for the first image, 1 for the second and so on.
1
1

The contents of the token in this case is controlled by the formatter that renders the image. Perhaps the formatter has a setting to render the image as a direct link instead? I haven't tried doing this in Drupal 7, but with imagefield in D6 there was a direct link option.

If not, the best way to solve this is to add such a formatter.

5
  • Great, thanks for the tip. I ended up using a module to do this. Image URL Formatter (drupal.org/project/image_url_formatter). It created a new Formatter option called "Image URL," and I can use that as a token.
    – Brad
    May 25, 2012 at 17:11
  • Glad you got it working. :) You should post that as an answer though, so you can accept it and the question becomes answered. Or it will remain in the "unanswered questions" queue forever.
    – Letharion
    May 25, 2012 at 17:13
  • Ha, gotcha. I was just wondering if I did that right...
    – Brad
    May 25, 2012 at 17:13
  • It certainly sounds right, and the answer that works for you is by definition the one you should accept. I would just have thought no extra module was necessary.
    – Letharion
    May 25, 2012 at 17:16
  • From what I've read, I believe they took the image path formatter option away in Drupal 7? The only option under "Formatter" that I saw was "Image." I wasn't sure how to manually create a custom formatter, so I went with the module.
    – Brad
    May 25, 2012 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.