Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the src of the image field in a view in drupal

We were working with Drupal 7 and trying to rewrite the views output

We need the src of the image field , not the whole image tag.

Clicking on

Rewrite the output of this field

[field_first_image] : Gives the whole content ie with tag ,

We tried to display the below ones

[field_first_image-fid] == Raw fid

[field_first_image-alt] == Raw alt

[field_first_image-title] == Raw title

But the same ( [field_first_image-fid] ) thing is displayed in the view. Is there a way we can get the src from the views rewrite ?

like image 362
Hari K T Avatar asked Jul 20 '11 13:07

Hari K T


2 Answers

If you don't want to need to install a module for this, there is a solution.

  • Create a new relationship
  • Select your image field (this will create a relationship to the file entity)
  • Add a field to your view
  • Select File: Path
  • Check Display download path instead of file storage URI

Note that this will create a URL to the original image, not to an image produced when applying an image style (like cropping, resizing etc.) so this may not work in every scenario.

like image 122
aross Avatar answered Nov 12 '22 07:11

aross


Image URL Formatter

This module add a url formatter for image field. Then you can output image url directly.

like image 18
maestro888 Avatar answered Nov 12 '22 06:11

maestro888