Drupal Answers Asked by Yoric on October 26, 2021
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>
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>
Answered by xurshid29 on October 26, 2021
I use IMAGE URL FORMATTER module
Then on view's, click on your field, for formatter you can select Image URL.
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
Answered by No Sssweat on October 26, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP