I'm trying to rewrite the output of a view, wrapping two fields in a link. But the link is not wrapping the fields, but instead several empty <a> tags are inserted in a few places. I have this successfully working in another view, but I suppose in this case the output of a rendered YouTube video thumbnail is causing issues.

The rewritten output looks like this:

<a class="inner">
  <div class="li-img">[field_okv_youtube]</div>
  <div class="li-text">[title] </div>
</a>

The [field_okv_youtube] field is a YouTube video thumbnail using the formatter "Rendered file".

The output of the above is like this:

<div class="views-row views-row-1">
  <div>
  <a class="inner"></a>
  <div class="li-img">
    <a class="inner"></a>
    <div id="file-190" class="file file-video file-video-youtube contextual-links-region">
    <a class="inner"></a>
      <h2 class="element-invisible"><a class="inner"></a><a href="http://youtube.com/watch?v=3Vkz65hB0es">ÖKV Play - Avspark Kronoberg - 11 juni 2013</a></h2>
      <div class="content">
        <img typeof="foaf:Image" src="https://example.com/sites/default/files/styles/vod_thumbnail/public/media-youtube/3Vkz65hB0es.jpg?itok=BRElG41y">  </div>
      </div>
    </div>
  <div class="li-text">Avspark Kronoberg - 11 juni 2013 </div>
  </div>
</div>

How can I wrap the YouTube thumbnail + title fields in a link when the above gets messed up?

Comments

Did you ever find a solution? I have the same issue.

What exactly is producing all that crud - links, foaf etc...?

Just worked it out.

In Views, in the relevant Content:Video field....
Under 'REWRITE RESULTS'
'Strip HTML tags'
but 'preserve certain tags' - preserve "Only local images are allowed." - thus dumping everything but the image.

Took me hours and such a simple solution. Why, Drupal, why?

Issue summary:View changes

Wrapped tag in code