Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I'm using Panels to generate my front page. In one of the panes in my panel layout, I want to have an image which is linked to a given URL. The image and URL are going to be managed by my users.

I've been told that the Link module will give me a field type for URLs., and the Link Image Formatter module will let me link images to URLs; but I can't find any documentation on how to actually use the link image formatter. (EDIT: It turns out the Link Image Formatter wasn't about making href links, but just including images from a different domain.. or something, I'm confused.)

I've tried creating a content type with an image field, and a link field, but I can't find any way to connect them, or any way to associate an image with the link field.

EDIT: The URL may be internal to the drupal site or it may be external. These image/link combinations will be created and managed by the user through drupal. There may be 4 of them on the front page, but I may need to use them more later on throughout the site. They aren't unique to each user, I'll only have one admin user who will be posting all of the content on the site.

I want the user to add a piece of content. They'll upload an image and they'll define the URL they want that image to link to. Then in one of my Views/blocks, I can select that content type and show it in a certain region. It'll just show the image, but if a user clicks on the image, it'll take them to the specified URL which may be external to the site.

This seems like a wheel that should already have been invented, but I'm having trouble finding them.

How can I achieve this?

EDIT: I figured out what I was doing wrong... I think the person who suggested the Link Image Formatter module to me may have hastily picked the wrong url when they sent it to me and really meant to send the Link Image FIELD module which does exactly what I expected.

share|improve this question
1  
Could you be more specific about what you're trying to do? For example, is the URL always going to link to somewhere else within the website, or could it be an external URL as well? How many of these will there be? Will all users be able to manage these, and will they be unique for each user? –  Patrick Kenny May 30 '12 at 5:21
    
Hi Patrick, I've updated my question to hoping answer yours. –  Kenny Wyland May 30 '12 at 16:28
add comment

2 Answers 2

you can load a image from a node.

 $prev_node = node_load($prev->nid); 
    $image = field_get_items('node', $prev_node, 'field_image');
     $img = field_view_value('node', $prev_node, 'field_image', $image[0], array(
      'type' => 'image',
      'settings' => array(
      'image_style' => 'thumbnail',
      'image_link' => 'content',
     ),
   ));

then if you get the image, linking image to a certain url can be easily done by

 $options = array(
            'html' => TRUE,
            'attributes' => array(
                'title' => $prev_node->title
            )
 );     
 $output = l($img, "your url", $options);
 print render($output);
share|improve this answer
    
Where would I put this code? –  Kenny Wyland May 30 '12 at 16:45
add comment
up vote 1 down vote accepted

I figured out what I was doing wrong... I think the person who suggested the Link Image Formatter module to me may have hastily picked the wrong url when they sent it to me and really meant to send the Link Image FIELD module which does exactly what I expected.

Link Image Field module is the right one. It let's you create a field in your content type of type "Link Image" and when you add content and upload an image, it asks you for the URL you want to link it to. I knew this had to have been solved before me, I was just using the wrong, but similarly named, module.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.