0

I created a view that displays my user profile picture. I created a template for this view using 'views-view-fields--name.tpl.php. This is the output I get.

<div class="view-content">
  <div class="views-row views-row-1 views-row-odd views-row-first views-row-last">
      <div class="field-content profile">
        <div class="user-picture">
          <img typeof="foaf:Image" src="/default_profile_picture.jpg" />
        </div>
      </div>
  </div>
</div>

What I want to do is add a link to my image, like so:

 ...<a href="#"><img></img></a>...

But it keeps adding that line to just before the "user-picture" div, and I want it after it. Is there any way to achieve this? Custom templates seems to not do the trick.

1

You can do this in the views ui.

  • Create a custom field
  • Hide the display of the image field
  • Use tokens provided to add image field output to your custom field

Example:

<a href="#">[image_field]</a>

UPDATE

Also ensure the style options are set to none on the image field so you don't get any div wrappers.

  • Thanks Alex. But I tried that. Still prints out the '.user-picture' <div> before the <img> – jae.phoenix May 13 '15 at 9:25
  • Have you changed the style options for the image field? These should be set to 'none'. – Alex Gill May 13 '15 at 9:44
  • 1
    What I have also done, is in the styling options, to select the field value and select -NONE- for HTML Element. That removes the default <div> created around the field element. – jae.phoenix Jun 1 '15 at 10:18

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.