Sutherland Boswell
Forum Replies Created
-
If you upload an image to a non-video post and “set as featured image” do you also get doubled thumbnails?
My guess is that your theme already has the code for featured images, which is showing one of the video thumbnails on your post. Then the plugin probably checks for a featured image or the first image in a post and adds it to the excerpt, which would show a second thumbnail for posts with a featured image (like those set manually by you or by video thumbnails).
My suggestion for if setting a featured image on a non-video post also shows two thumbnails is disabling the other plugin and setting a featured image when creating a post. Otherwise you’ll need to dig into your theme’s code just a little and get it to do the same thing. Since that plugin hasn’t been updated since 2009, you’re bound to run into some other problems sooner or later.
Did a little testing myself and apparently the post’s status must be getting changed to draft before being privately published. I managed to get
draft_to_privateto work after creating a new post, switching it to private, and then clicking “Update”.I think the solution may be to just simplify things and only use the
save_posthook.I tested this out and it seems to work fine, can do a little testing to see if it works for you without creating duplicate images?
// Find video thumbnail when saving a post, but not on autosave or revisions add_action( 'save_post', 'save_video_thumbnail', 10, 1 ); function save_video_thumbnail( $post_id ) { if ( !wp_is_post_revision( $post_id ) ) { $post_type = get_post_type( $post_id ); $video_thumbnails_post_types = get_option( 'video_thumbnails_post_types' ); if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return null; } else { // Check that Video Thumbnails are enabled for current post type if ( in_array( $post_type, (array) $video_thumbnails_post_types ) || $post_type == $video_thumbnails_post_types ) { get_video_thumbnail( $post->ID ); } else { return null; } } } }Thanks again for your help!
@elwinge good catch, I think I know what needs fixing now
That’s odd, it’s supposed to exist
It looks like this may be from a bug in Viper’s Video Quicktags. I was testing it out and this is the code VVQ is embedding the video with:
<span class="vvqbox vvqdailymotion" style="width:480px;height:221px;"><span id="vvq-923-dailymotion-1"><a href="http://www.dailymotion.com/videoxn9mou">http://www.dailymotion.com/videoxn9mou</a></span></span> <script type="text/javascript"> swfobject.embedSWF("http://www.dailymotion.com/swf/xn9mou&colors=&autoPlay=0&related=0", "vvq-923-dailymotion-1", "480", "221", "10", vvqexpressinstall, vvqflashvars, vvqparams, vvqattributes); </script>The URL http://www.dailymotion.com/videoxn9mou is missing a slash and should actually be http://www.dailymotion.com/video/xn9mou. You can try visiting both URLs and see that the first cannot be found.
In vipers-video-quicktags.php try changing line 3040 (or somewhere in that area) to
return '<span class="vvqbox vvqdailymotion" style="width:' . $atts['width'] . 'px;height:' . $atts['height'] . 'px;"><span id="' . $objectid . '"><a href="http://www.dailymotion.com/video/' . $videoid . '">http://www.dailymotion.com/video/' . $videoid . '</a></span></span>';This fixed the problem for me, so I’ll notify Viper007Bond about it.
I just tested it out with that URL but it worked for me, can you try it with a Vimeo video and see if it works for that?
It looks like you’re using a commercial theme which means I can’t take a look at the source, but it does seem like it probably has a lot of custom functionality built in.
Can you try adding
add_action('new_to_private', 'save_video_thumbnail', 10, 1);to the section below and let me know if that fixes the problem for private posts?add_action('new_to_publish', 'save_video_thumbnail', 10, 1); add_action('draft_to_publish', 'save_video_thumbnail', 10, 1); add_action('pending_to_publish', 'save_video_thumbnail', 10, 1); add_action('future_to_publish', 'save_video_thumbnail', 10, 1);Early on I was having trouble getting the action to run without creating duplicates for every revision or auto-save, and adding actions for these post status transitions was the best solution I could come up with at the time. I’m gonna be working on version 2.0 soon (your help has provided a good motivation) with several optimizations and this is probably one of the things I’ll try to improve.
TextWrangler does a pretty good job of comparing differences, I went through and included all the changes as well as converting all indentation to tabs.
Here’s where I’m at: 1.7.8-working
So you aren’t getting anything when the post is published and have to use the “search again” button every time?
According to the documentation on AJAX in plugins, die() is required at the end of a callback function.
I think the best solution would be to store the image’s media library ID in the custom field instead of an absolute path. This would make things a lot more flexible and manageable all around for people who want to delete all video thumbnails, change domains, get different media sizes, etc.
The fact URLs are stored is a remnant of the early versions when images weren’t being saved to the local media library. I think it’s about time to drop support for storing non-local URLs.
Another thing that might help would be custom fields for attachments created by video thumbnails, that way a user could click a button and any media with a field like ‘is_video_thumbnail’ could be wiped out.
Got the changes incorporated and made some additional changes that will hopefully fix the blank settings page bug some people were seeing. About to publish as 1.7.7, thanks again!
PS – Just saw your 1.7.6-daedalon2 version a bit too late, those changes won’t be included in this version.
I don’t think this is something we need to worry about, because the links (at least those the core supports) should already be converted to their embed code by applying the content filter.
$markup = $post_array->post_content; $markup = apply_filters('the_content',$markup);This is also supposed to take care of any videos embedded using plugins with their own shortcode or URL structure, but for some reason this isn’t always the case. Maybe try testing out this section to see if it is in fact converting most videos from the core and plugins to their embed code.
Thanks Daedalon, I’m gonna try to work these in as soon as I have a little time. It’s tough debugging all the issues with all the different hosting environments and video setups, so I really appreciate the help.
Forum: Plugins
In reply to: [Video Thumbnails] [Plugin: Video Thumbnails] Can't Find YouTube Thumbnails@Chozen @bazel it sounds like maybe the custom fields aren’t being saved until after the Video Thumbnail action. Try changing
add_action('new_to_publish', 'save_video_thumbnail', 10, 1); add_action('draft_to_publish', 'save_video_thumbnail', 10, 1); add_action('pending_to_publish', 'save_video_thumbnail', 10, 1); add_action('future_to_publish', 'save_video_thumbnail', 10, 1);in the plugin file to
add_action('new_to_publish', 'save_video_thumbnail', 20, 1); add_action('draft_to_publish', 'save_video_thumbnail', 20, 1); add_action('pending_to_publish', 'save_video_thumbnail', 20, 1); add_action('future_to_publish', 'save_video_thumbnail', 20, 1);and let me know if this fixes the problem for you. I’m going to try to include official custom field support in an upcoming version, and I’ll include this change if it fixes your problem.
Thanks Daedalon, I should probably just remove everything before
youtube.com