Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#8 | Screen Shot 2015-03-08 at 17.44.23.png | 182.31 KB | featherbelly |
#2 | video_embed_field-emptyurl-1904844-7011572.patch | 1.52 KB | cmalek |
video_embed_field.emptyurl.patch | 1.67 KB | cmalek | |
Comments
Comment #1
mrweiner CreditAttribution: mrweiner commentedI'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:
Comment #2
cmalek CreditAttribution: cmalek commentedThis 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.
Comment #3
mrweiner CreditAttribution: mrweiner commentedLooks 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.
Comment #4
mrweiner CreditAttribution: mrweiner commentedUnfortunately, 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:
I suppose this is just about the same as before, but the
href
portion is not being included. Any ideas?Comment #5
mrweiner CreditAttribution: mrweiner commentedI 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.
Comment #6
cmalek CreditAttribution: cmalek commentedYes, 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().
Comment #7
plopescHello
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.
Comment #8
featherbellyHello,
It seems to happen when there is more than one entry present on a multi-value field but there is no actual content....
I've attached a screenshot of the $content output using Krumo.
Anyway - it does seem to happen on rare occasions....
I have added some checks in my node.tpl.php to work around this but not ideal.