Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Kyle Gilman

    (@kylegilman)

    You could add the duration to the thumbnail images generated by my plugin, but it wouldn’t be as easy as turning on an option. There are a lot of different ways to accomplish it and it depends on how you want it to work. Do you want the text to be part of the image so no matter what context it’s displayed in you’ll have the duration on it? Or do you want it as an HTML/CSS overlay in certain contexts so you don’t have it on the video player thumbnail but do have it on a thumbnail image that links to the video player?

    I don’t understand what you’re asking about the video description and a URL. Can you be more specific?

    Thread Starter yamiraan

    (@yamiraan)

    Thanks soo much for a detailed response,
    what is the best way to get video duration on thumbs, i just want to show video duration on thumbs, a sample screen short is attached to understand how i want
    https://azadarimission.com/test/2.jpg
    and in post description section i dont want to show video image url, a screen shot is attached
    https://azadarimission.com/test/1.jpg

    can we hide this url
    [KGVID]https://azadarimission.com/wp-content/uploads/2016/05/Nadeem-Sarwar-Woh-Bakamal-Hai-2009.mp4[/KGVID]
    anywhere in sttachement o somewhere else but not in description section?
    Thnaks

    Plugin Author Kyle Gilman

    (@kylegilman)

    Ok, I think I’m getting it. This isn’t really something my plugin can do, but it is something you can do to your theme using built-in WordPress functions. Both of these solutions will require editing your theme. I suggest creating a child theme so you can continue to get updated versions of the parent theme. My assumption is that on your site you always have one video attached to one post.

    For the duration thumbnail overlay, find the part of your theme that displays the thumbnails, copy that file and put it in your child theme’s directory. Find the part of that file that outputs code like this <div class="image-holder"> and immediately after that, add this code. You’ll have to determine whether you’re in PHP or HTML mode and whether you need to echo the code or not, since I don’t have access to your theme files. This assumes that we’re in the loop and the global $post variable is available to us.

    THIS CODE HAS NOT BEEN TESTED AND YOU SHOULD BE ABLE TO TROUBLESHOOT CODE AND EXPECT TO HAVE YOUR SITE GO DOWN WHILE YOU ARE WORKING ON IT.

    <?php
    
    $args = array(
    	'numberposts' => 1,
    	'post_mime_type' => 'video',
    	'post_parent' => $post->ID,
    	'post_status' => null,
    	'post_type' => 'attachment',
    );
    
    $video_attachments = get_posts($args);
    
    if ( $video_attachments ) { //if there's a video attached to this post
    	foreach ( $video_attachments as $video ) {
    		$attachment_meta = wp_get_attachment_metadata($video->ID);
    		if ( is_array($attachment_meta) && array_key_exists('length_formatted', $attachment_meta) ) { //if WordPress knows the duration of your video
    			echo '<span class="duration-overlay">'.$attachment_meta['length_formatted'].'</span>';
    			break; //only get one duration
    		}
    	}
    }
    ?>

    Add this to the style.css file in your child theme

    .duration-overlay {
        display: inline-block;
        position: absolute;
        bottom: 4px;
        left: 5px;
        padding: 3px;
        color: white;
        line-height: 11pt;
        font-size: 9pt;
        background-color: rgba(0,0,0,0.6);
        border-radius: 4px;
        box-shadow: 0px 0px 3px white;
    }

    This other thing should save you a lot of time. Find the part of your theme that outputs the $post->post_content in single posts. Above that, add this code:

    <?php echo do_shortcode('[KGVID][/KGVID]'); ?>

    This will automatically embed any videos attached to the post and you don’t have to put any shortcode in the post content window.

    Thread Starter yamiraan

    (@yamiraan)

    video duration is working now but im not able to hide embed code in post content box, can you please guide me bit more, i really appreciate it ,
    i dont want to show video embed code in post content box, let me attach again screen short, hope you have any solution, thanks
    https://azadarimission.com/test/1.jpg

    Plugin Author Kyle Gilman

    (@kylegilman)

    It’s great to hear the duration is working.

    The way to do hide the code is to not put any video embed code in the post content box, and instead modify your template again to automatically add videos to your posts. This time you need to find the part of the template that generates a single post. It depends on a lot on how the template is designed, but you should be able to find something like $post->post_content. Above that, add this code:

    <?php echo do_shortcode('[KGVID][/KGVID]'); ?>

    Thread Starter yamiraan

    (@yamiraan)

    something im misunderstanding i need to hide code in admin panel where we add a new post but you are explaining me to hide embed code through template edit, if we edit the theme than embed code will not show in post content box in admin panel?
    sorry im new on wp and have a very basic knowledge, you know why i dont like this code in content box, there are two reasons may be you can guide me, the first reason is i think in post content box we should add some text about post for better seo, and second reason is when i share this video on FB this weird code also show below the video image, it dont look like professional, hope we can find any better way for these problems,
    Thanks

    Plugin Author Kyle Gilman

    (@kylegilman)

    I see. What you’re asking for isn’t going to solve your problem. Hiding the [KGVID] shortcode in the admin area won’t change what shows up in Facebook when you share the video. Facebook is picking up on the text within the rendered video on the page, so you need to provide it with something else to use. Since you don’t have https enabled on your site you can’t use my plugin’s Facebook tags to embed the video directly in Facebook, but Yoast’s SEO plugin should be able to generate a description for you. Right now you don’t have any text for the plugin to make into a description. The [KGVID] shortcode—and all shortcodes—are automatically ignored by SEO plugins so you don’t need to worry about hiding it. Have you tried adding text in the post content box after the video shortcode? In my experience Yoast’s plugin will automatically pick up on that text and generate a Facebook meta tag using the text you add after the shortcode which will replace all that weird code when you share it on Facebook.

    Thread Starter yamiraan

    (@yamiraan)

    Thank you soo much, your last posy eliminate my all problems, now im very near to my project, now please help me to create MP3 file, means when i upload any video file plugin have to create MP3 file also, my project is a video music site but also MP3 files available of any video , Tanka

    Plugin Author Kyle Gilman

    (@kylegilman)

    Sorry, my plugin doesn’t make mp3s out of videos and I don’t know of a service that could do that for you.

    Thread Starter yamiraan

    (@yamiraan)

    no problem you already help me a lot to solve my major problems,

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Video Duration’ is closed to new replies.