1

I have the following code that is showing the url of a file meta key:

$images = get_post_meta( $post->ID, 'video_of_user' );
if ( $images ) {
    foreach ( $images as $attachment_id ) {
        $thumb = wp_get_attachment_image( $attachment_id, 'thumbnail' );
        $full_size = wp_get_attachment_url( $attachment_id );

        printf( '<a href="%s">%s</a>', $full_size, $thumb );
    }
}

Instead of showing just the URL in an HREF, i with it to play inside the WordPress default media player.

so i am using "do_shortcode" for "[video]". what i can't seem to do is to add the:

printf( '<a href="%s">%s</a>', $full_size, $thumb );

Inside the do_shortcode. something like that:

<?php echo do_shortcode( '[video width="100%" height="472" m4v="MY-VIDEO-URL"][/video]' ); ?>

i have tried doing this:

<?php echo do_shortcode( '[video width="100%" height="472" m4v="'%s', $full_size, $thumb"][/video]' ); ?>

But it dosn't seem to work.

I have also tried:

$images = get_post_meta( $post->ID, 'video_of_user' );
if ( $images ) {
    foreach ( $images as $attachment_id ) {
        $thumb = wp_get_attachment_image( $attachment_id, 'full' );
        $full_size = wp_get_attachment_url( $attachment_id );

        echo wp_get_attachment_url( $attachment_id, 'full' );

    }
}

And then:

 <?php echo do_shortcode( '[video width="100%" height="472" m4v="'. wp_get_attachment_url( $attachment_id, 'full' ) .'"][/video]' ); ?>

But this also don't work.

1 Answer 1

1

have you tried this?

$images = get_post_meta( $post->ID, 'video_of_user' );
if ( $images ) {
    foreach ( $images as $attachment_id ) {
        $thumb = wp_get_attachment_image( $attachment_id, 'full' );
        $full_size = wp_get_attachment_url( $attachment_id );

        $url = wp_get_attachment_url( $attachment_id, 'full' );
        echo do_shortcode( '[video width="100%" height="472" m4v="'. $url .'"][/video]' ); ?>

    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.