If the field is empty (has no value), the renderer outputs this, which is unsightly:

<div class="embedded-video">
  <div class="player">
    <a href="http://">http://</a>  </div>
</div>

I believe this is because template_preprocess_video_embed_field_embed_code() in video_embed_field.module doesn't check whether $variables['url'] is empty before using it to build $variables['embed_code']. $variables['embed_code'] ends up as the content of the "class="player"" div, above.

Attached is a patch that should fix this.

Comments

I'm having this same issue, but it is happening to me when the field is filled with a url, and is being loaded into a colorbox. The content of the colorbox is then exactly what you described. When there is nothing in the field it doesn't show up at all, and when I have the field load as normal, without a colorbox, it shows the video like it would if it were embedded anywhere else.

Are you sure you are only having this problem when the field is empty? Is this a recent development, or has it been doing this to you for a while?

For me, it seems like this issue occurred recently. I know everything used to work fine, but I went to check a video two days ago and this problem popped up. No idea why.

Also, when I try to apply your patch I get:

patching file video_embed_field.module
Hunk #1 FAILED at 345.
Hunk #2 FAILED at 559.
2 out of 2 hunks FAILED -- saving rejects to file video_embed_field.module.rej

This just started happening for us when we updated to 7.x-2.0-beta5 last week, and yes, it's only when the field is empty. When the field has a value, the video is embedded properly. We're not embedding in a colorbox, however.

re: my patch. Sheesh, you are right. I must not have been on the branch I thought I was on when I made that patch. I've attached a working patch.

Priority:Normal» Major
Status:Active» Reviewed & tested by the community

Looks like the patch is still not applying correctly for me. But now I am getting Hunk #1 FAILED at 347. I'd fix that myself, but I'm not sure how. It's possible that I added line breaks into my module file or something, and that's why it won't apply. I'm guessing the issue is on my end.

In either case, I applied the changes manually and they seem to fix the problem. Thanks a bunch.

Status:Reviewed & tested by the community» Active

Unfortunately, it seems that this only fixed the problem momentarily. I have no idea why that would be, but since you seem to have fixed it once, maybe you can offer me a suggestion.

Instead of the original garbage output, it is now rendering:

<div class="embedded-video">
<div class="player"> </div>
</div>

I suppose this is just about the same as before, but the href portion is not being included. Any ideas?

Status:Active» Reviewed & tested by the community

I realized that my problem is somewhat separate from this one, so I opened up another issue at #1908058: $variables array not being built correctly when using colorbox.. Sorry for flooding the thread. It appears that your patch does indeed work as intended, and that's why I'm now seeing nothing instead of the "http://". Status is being changed back. Hopefully this gets committed soon.

Yes, I didn't know how to make it simply not render the field at all if the field has no value in the database, so I made it simply not show the <a> which was what was bugging me.

It may be that a better place to deal with empty fields is in video_embed_field.inc:video_embed_field_field_formatter_view().

Issue summary:View changes
Status:Reviewed & tested by the community» Postponed (maintainer needs more info)

Hello

I'm trying to reproduce the bug described in this issue, but I can't.

Leaving the URL video field empty, video_embed_field_field_formatter_view() returns an empty array and no HTML data is output.

Please, let me know the necessary steps to reproduce your bug and try to find the better fix possible.

Regards.