WordPress.org

Ready to get started?Download WordPress

Forums

Can you make Viper's Video Quicktags to work with a custom field too ? (8 posts)

  1. xxxxxcata
    Member
    Posted 4 years ago #

    Is there a way to enable this plugin for custom fields ?

    Let's say I'm paste this code in custom field named embed

    [youtube]http://www.youtube.com/watch?v=k8fLRPETv_0[/youtube]

    ------------------------------------

    then I'm showing like this

    <?php query_posts('tag=video&showposts=1'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php woo_get_custom('embed'); ?>
    <?php endwhile; ?>

    ------------------------------------

    And the function woo_get_custom is here:

    // Get Custom Embed
    function woo_get_custom($key, $width=0, $height=0) {

    global $post;
    $custom_field = get_post_meta($post->ID, $key, true);

    if ($custom_field) {

    if ($width == 0) :
    // Get custom width and height
    $width = get_post_meta($post->ID, 'width', true);
    $height = get_post_meta($post->ID, 'height', true);
    endif;

    // Set values
    if ( !$width ) $width = 'width="313"'; else $width = 'width="'.$width.'"';
    if ( !$height ) $height = 'height="250"'; else $height = 'height="'.$height.'"';

    $custom_field = preg_replace( '/width="[^"]+"/' , $width , $custom_field );
    $custom_field = preg_replace( '/height="[^"]+"/' , $height , $custom_field );
    ?>
    <div class="video">
    <?php echo $custom_field; ?>
    </div>
    <?php
    }
    else { //else, return
    return;
    }
    }

    Thank you very much, great job :)

  2. $custom_field = apply_filters( 'the_content', $custom_field );

    That'll replace the shortcode with the embedded video.

    If you need to modify the width/height of the video, use vvq_shortcodeatts filter.

    add_filter( 'vvq_shortcodeatts', 'your_function' );
    
    function your_function( $atts, $tag, $rawatts ) {
    	if ( is_home() ) {
    		$atts['width'] = 123;
    		$atts['height'] = 456;
    	}
    
    	return $atts;
    }
  3. natebedortha
    Member
    Posted 4 years ago #

    this method doesn't appear to work with QuickTime embeds. qtobject.js doesn't get attached.

    thanks!

  4. xxxxxcata
    Member
    Posted 4 years ago #

    Thank you very very much, Viper007Bond, but...

    My new function is like this:

    //  Get Custom Embed
    function woo_get_custom($key) {
    	global $post;
    	$custom_field = get_post_meta($post->ID, $key, true);
    	$custom_field = apply_filters( 'the_content', $custom_field );
    	if ($custom_field) {
    ?>
    
    <div class="video">
    	<?php echo $custom_field; ?>
    </div>
    
    <?php
    	}
    	else { //else, return
    		return;
    	}
    }

    I want to call it like this

    <?php woo_get_custom('embed','354','272');  ?>

    Notice that I want to give custom width and height on this video.
    (I'am a beginner in php)

  5. Sorry, but I can't code up custom code for everyone who asks.

    You're on your own.

  6. xxxxxcata
    Member
    Posted 4 years ago #

    Hmmm, I hate this attitude ... you did a great job but close this if your are not offering support. I have over 3000 visits/day on my blog, I was wanted to write about you and your quick feedback/support, but now I'm disappointed. For you it was a matter of 5 or 10 minutes. For me it's harder. I make xhtml & css & flash , not php.

  7. Hmmm, I hate this attitude ... you did a great job but close this if your are not offering support.

    It's okay, I hate your attitude too. ;)

    It's a free plugin, one which I spent countless hours coding and will result in very little benefit for me. Just because I wrote a plugin and released it does not mean I am required to support it. Infact the license pretty much says exactly that.

    I'm happy to spend a little time offering basic support for my plugin and it's code, but I'm not going to sit down and write code for you just because you don't know how and aren't willing to learn.

  8. xxxxxcata
    Member
    Posted 4 years ago #

    aren't willing to learn

    Hmm, I want to learn ;) I am a xhtml, css developer.
    Here you have http://portfolio.webworks.ro/
    I have there websites like BMW ;)
    Anyway thanks for your support.

Topic Closed

This topic has been closed to new replies.

About this Topic