0

Created a content type called Gallery and added the image style for that. The images are to be displayed in the page--front.tpl.php

I have fetched the images using this,

<div class="bannerSlider">

            <div class="slider-wrapper theme-default">
                <div id="slider" class="nivoSlider">    
                        <?php
                        $nid=11;
                        $node = node_load($nid);
                        $imgcount = count($node->field_img['und']);
                        for ($i = 0; $i < $imgcount; $i++) {
                        $image_uri = $node->field_img['und'][$i]['uri'];
                        // url
                        $masthead_raw = image_style_url('gallery-thumb', $image_uri);
                        ?>
                            <img src="<?php print $masthead_raw; ?>">           

                     <?php } ?> 
                </div>
             </div>. 

The image is not displaying.Please guide me.

0
2

You need to convert that public://myname.jpg to an actual URI to pass to an img tag

Try image_style_url

Replace your code with this

<div class="bannerSlider">
 <div class="slider-wrapper theme-default">
  <div id="slider" class="nivoSlider">    
    <?php
    $nid=11;
    $node = node_load($nid);
    $imgcount = count($node->field_img['und']);
    for ($i = 0; $i < $imgcount; $i++) {
//$image_uri = $node->field_img['und'][$i]['uri'];
      $yourimagestylename = 'MY_IMG_STYLE';
      $image_uri = image_style_url($yourimagestylename,$node->field_img['und'][$i]['uri']);
// url
      $masthead_raw = image_style_url('gallery-thumb', $image_uri);
      ?>
      <img src="<?php print $masthead_raw; ?>">           

      <?php } ?> 
    </div>
  </div> 
0

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.