1

I successfully print the image url for a individual images by the following:

$file = file_load($node->field_hp_slideshow_image['und'][0]['fid']);
                print file_create_url($file->uri);

How can I do something similar but display the url of multiple images in a for or for each loop? Below I have this but it doesn't work:

<?php $slide_image = $node->field_hp_slideshow_image['und'];
    $slide_url = $node->field_hp_slideshow_link['und'];
    $file = file_load($node->field_hp_slideshow_image['und'][0]['fid']);
    print $field_hp_slideshow_image['und'][0]['filename'];
    print file_create_url($file->uri);
?>
<?php for ($i = 0; $i < count($slide_image); ++$i): ?>
    <div class="slideContent">
        <a href="<?php print $slide_url[$i]['url']; ?>">
        <img src="<?php print $base_url . "/" . $path . "/" . $slide_image['filename']; ?>" alt="" />
        </a>
    </div>
<?php endfor; ?>
1

Install Image URL Formatter and change the format to its url. To do so create a view of set of nodes, select the image as the field and change its format to URL. You can also change the format to URL in the manage display of the content type.

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.