Hi
I am new to drupal (using drupal 7) and PHP. I am developing a site for vintage bikes company. I have a block on right of home page called 'Featured Bike'. This block displays: one featured bike image and its model name as title at a time, from nodequeue and views.
I am struggling to get this featured bike image (which is image field) as backdround-image of the div which holds it.
I was able to add theme_image() as preprocess function in template.php.
function theme_image($variables) {
$attributes = $variables['attributes'];
$attributes['src'] = file_create_url($variables['path']);
foreach (array('width', 'height', 'alt', 'title') as $key) {
if (isset($variables[$key])) {
$attributes[$key] = $variables[$key];
}
}
return '<img' . drupal_attributes($attributes) . ' />';
}
This function is returning the 'img' tag along with 'src, title, alt, height and width' info.
In my views-views-nodequeue-1-fields.tpl.php file, one of the allowed variables is $fields.
When i do something like this:
<div style="background-image: url(<?php print $fields['entity_id']->content; ?>)>
The value of $fields['entity_id']->content prints img src="..." alt="..." and so on..
Whereas I only want to extract the path of the $fields['entity_id']->content and print it in the url of BG image.