我有以下代码显示文件元键的URL:
$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 );
}
}
我没有只显示HREF中的URL,而是在WordPress默认媒体播放器中播放。
所以我使用“do_shortcode”作为“[video]”。我似乎无法做的是添加:
printf( '<a href="%s">%s</a>', $full_size, $thumb );
在do_shortcode中。类似的东西:
<?php echo do_shortcode( '[video width="100%" height="472" m4v="MY-VIDEO-URL"][/video]' ); ?>
我试过这样做:
<?php echo do_shortcode( '[video width="100%" height="472" m4v="'%s', $full_size, $thumb"][/video]' ); ?>
但似乎没有用。
我也尝试过:
$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' );
}
}
然后:
<?php echo do_shortcode( '[video width="100%" height="472" m4v="'. wp_get_attachment_url( $attachment_id, 'full' ) .'"][/video]' ); ?>
但这也行不通。
答案 0 :(得分:1)
$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]' ); ?>
}
}