Search code examples
urldrupal-7

Drupal 7: how to get image url to display image


In Drupal 7, I'm using the feeds module to pull in a bunch of books

That's all working perfectly. I am not setting up some views. the feed pulls in an image url to on o my field like this [http://img.techbook.com/techwords/content/bk/blak/003834/full_image.jpg but of course I need

<img src="http://img.techbook.com/techwords/content/bk/blak/003834/full_image.jpg" />

to display the image on the page

What is the best method of altering this fields' text, or is there a method so I can automatically format correctly. There are hundres of these, so manually do it is not an option


Solution

  • You can either use Feeds Tamper, which let's you manipulate the incoming feed data before it comes in (ie. wrap the url with img tags): http://drupal.org/project/feeds_tamper

    OR

    You can simply import the URLs into a field, and then render the URL with a template file that has the img tag wrapped around the field.

    Like so: in node--content-type-name-here.tpl.php

    <img src="<?php print render($content['field_url']); ?>" />
    

    I would recommend the latter and only use Feeds Tamper for more serious manipulations.