Reputation: 1719
I have an IF/ELSE statement and I would like to print out some images that I am getting from my Drupal site. I can't figure out how to print those IMG tags without getting errors.
This is what I have so far:
<?php
$field = field_get_items('node', $node, 'field_visitor_image');
if($field){
<img src="<?php print image_style_url('lead_teaser', $node->field_visitor_image['und'][0]['uri']); ?>">
}
else
{
<img src="<?php print image_style_url('lead_teaser', $node->field_banner_image['und'][0]['uri']); ?>">
}
?>
Upvotes: 0
Views: 70
Reputation:
You cannot nest
<?php > inside another <?php >.
One option for you could be to concatenate using ".".
Upvotes: 0
Reputation: 780724
Use echo
and string concatenation:
if ($field) {
echo '<img src="' . image_style_url('lead_teaser', $node->field_visitor_image['und'][0]['uri']) . '">';
}
Upvotes: 3
Reputation: 943185
You have to break out of PHP mode when you start outputting HTML.
if($field){
?>
<img src="<?php print image_style_url('lead_teaser', $node->field_visitor_image['und'][0]['uri']); ?>">
<?php
}
Upvotes: 5