3

I have added a file field in views and when displaying it has some markup like this

 <div id="file-218" class="file file-image file-image-jpeg 
contextual-links-region">
<a href="#">

    </a>
       <h2 class="element-invisible">
  <a href="#"></a>
 <a href="/mdm.dev/file/218">6783c11f-0b05-49e3-a494-ca68d2e6c23b-2060x1366.jpeg</a></h2>
 <div class="contextual-links-wrapper contextual-links-processed">
<a class="contextual-links-trigger contextual-links-trigger-active" href="#">
Configure</a>
 <ul class="contextual-links">
 <li class="file-edit first">
  <a href="/mdm.dev/file/218/edit?destination=gallery-page">Edit</a> </li>
  <li class="file-delete last">
 <a href="/mdm.dev/file/218/delete?    destination=gallery-page">Delete</a></li>
 </ul></div>

<div class="content">
<img typeof="foaf:Image" 
src="http://10.200.1.10/mdm.dev/sites/default/files/
  styles/w206xh154/public/6783c11f-0b05-49e3-a494-ca68d2e6c23b-2060x1366.jpeg?itok=bk_SdoJ3" alt=""> 
</div>


 </div>

While all I need is

<img typeof="foaf:Image" src="http://10.200.1.10/mdm.dev/sites/default/files/
  styles/w206xh154/public/6783c11f-0b05-49e3-a494-ca68d2e6c23b-2060x1366.jpeg?itok=bk_SdoJ3" alt=""> 

How can I remove this markup. Can I use views-view-field-field_name.tpl.php. Only line this file contains is print $output. How can i use this file to remove markup. Or does any preprocess hook helps

2

2 Answers 2

0

You can use theme layer to override the views output , if you want only theme a certain field you can use this template file :views-view-field.tpl.php

for more information check this tutorial : Theming a single field in a Views

0

You can use Semantic Views module, it is good module that can help you get rid of unwanted Drupal wrappers.

Here are some more details about this module(quotes from its page):

This Views plugin makes unformatted styles, field row styles and other output more readily configurable without needing to override template files. Instead of overriding row style templates for views where you want to specify different HTML elements (tags) and class attributes, you can specify these inside the Views UI and avoid overriding templates for each view.

Some of Semantics Views functionality can be done in Views, but Views is restricted to use only predefined HTML element and can only style each Field but not wrap rows with any HTML you like.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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