0

I have a view in drupal 7 and I have created a template of this view. Now I need to call image here.

  • Is the image the result of view that you created? – Aparna May 29 '15 at 5:50
  • I am using <img src="<?php print image_style_url('home_recent_properties', $fields['field_real_thumbnail']->content); ?>" class="attachment-property-thumb" alt="" /> but its getting me nothing – jsh May 29 '15 at 6:07
  • What is the output of print_r($fields['field_real_thumbnail']->content); ? – Aparna May 29 '15 at 6:14
  • public:///20141030221735601699000000-1432878640-1 – jsh May 29 '15 at 6:25
  • I am using this here views-view-fields--dev-home-recent-properties--block.tpl.php view tpl file – jsh May 29 '15 at 6:26
0

Try this

<div class="attachment-property-thumb">
  <?php print $fields["field_real_thumbnail"]->content; ?>
</div>

enter image description here

enter image description here

  • public:///20141030221735601699000000-1432878640-1 getting this line after using this code. – jsh May 29 '15 at 8:04
  • On your view, when you configured the real thumbnail field, did you set the formatter to image? – No Sssweat May 29 '15 at 8:08
  • Great Thanks.. I have one other issue. here I am getting more then 1 image..But I need to use only one image.. – jsh May 29 '15 at 8:27
  • You want a specific image? or does it need to depend on something else like a user or a node? – No Sssweat May 29 '15 at 8:38
  • my images is comming from MLS listing.. And its giving me 10-11 images. And here I need only one image. not need any specific image. – jsh May 29 '15 at 8:41
0

If you have multiple images, please make changes from view to display only single image as shown in attached file.

Please use below code snippet in your view tpl file.

$fid = file_id_from_your_view

$file = file_load($fid);

$img_url = $file->uri;

// Path for your image with specific style
$style_image = image_style_url('your_image_style_to_display', $img_url);

Hope this helps you!

Thanks!enter image description here

0

You need to do field level theming.

  1. Create a template file having name like: views-view-fields--your-view-name.tpl.php

  2. drupal_set_message('<pre>' . print_r(array_keys($fields), TRUE) . '</pre>');

see Calling a field in views-view-fields--view-name.tpl.php ---- Error

  • this code display me Array ( [0] => field_res_remarks [1] => field_res_price [2] => field_res_combined_sqft [3] => field_res_total_baths [4] => field_res_bedrooms [5] => field_res_property_sub_type [6] => field_res_status [7] => field_geo_lat [8] => field_geo_lon [9] => id [10] => field_res_images [11] => field_res_listing_id [12] => field_res_street_name [13] => field_res_city [14] => field_res_mls ) – jsh May 29 '15 at 6:30
  • Plz go through the above mentioned URL. – Astha chauhan May 29 '15 at 6:32
  • I am able to fetch other variable value ..Only image giving me issue. – jsh May 29 '15 at 6:38
  • Please help . If you have any solution. – jsh May 29 '15 at 7:22

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