2

I have a content type (music) with fields(image,track,title). I used a soundmanager player to display my track with its tpl.php(bar.tpl.php).

I have tried to display url of the image field inside the (bar.tpl.php) but got only (http://localhost/mysite) using this code

<div class="sm2-inline-element album-art">
 <img src="<?php $file = file_load($node->field_image_boss['und'][0]['fid']); 
  print file_create_url($file->uri); ?>" />
</div>

2 Answers 2

0

I use IMAGE URL FORMATTER module

Then on view's, click on your field, for formatter you can select Image URL.

enter image description here

Then on your tpl.php file use <?php print $fields["field_image_boss"]->content; ?>

Note if you see that your field gets printed with extra markup such as <span>url</span> instead of just url. Then you need to remove extra views container markups

On your view's edit page. Under Format click on the 1st settings and uncheck Add views row classes and Add striping (odd/even), first/last row classes

Also, on the 2nd settings, uncheck Provide default field wrapper elements

Lastly, click on your field, and under STYLES SETTINGS make sure everything is unchecked

0

You can use image_style_url if you only want to dsplay an image. Like this:

<div class="sm2-inline-element album-art">
 <img src="<?php $file = file_load($node->field_image_boss['und'][0]['fid']); 
  print image_style_url('STYLE_NAME (e.g. large, or use custom)', $file->uri); ?>" />
</div>

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.