2

I have a content type that has an image attached. In a View I need to print the full path to the image.

I thought this would be easy but for some reason I cant figure it out. I can find the image field in the view, but when I rewrite the output I cant see any patterns for the file path.

In my view Ive created a relationship to the image field to the node, but this doesn't provide me with any more rewrite patterns, or any fields that look like they could be the image path.

4

Found the answer here: https://drupal.org/node/1051320

  1. Create your view as normal.
  2. Add your image field as normal.
  3. Go to relationships
  4. Add Relationship "File Usage"
  5. Go back to fields section
  6. Under groups, a new option "File" will appear

  7. Selecting file will output the path for every file field on your site. If you want it just for one particular image field follows these steps:

    • Add the new "File" field
    • In file field, select "exclude from display".
    • Go back to your image field (created in step 2)
    • Select "Rewrite the output of this field"
    • Under tokens, use the token for the file field (created in step 6). (NB the file field must come before the image field, or else the token will not appear).

Hope this helps somebody!

  • This works like a charm. I am using Drupal 7.56 & views 7.x-3.17 Just that after adding the Relationship for File, under fields a lot of file usage field options show up. I used the "File:Path" under fields. Then checked - Exclude from display & Display download path instead of file storage URI (otherwise, it will show public://path-to-image/image.png) – amohite88 Feb 2 '18 at 12:46
0

In D7 you need to add (or if none exists) a field formatter. In your case there already is a contributed one that does exactly what you need: display the URL instead if the image itself:

https://drupal.org/project/image_url_formatter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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