Forums

[resolved] Insert Youtube ID from Custom Field into Embed Code (3 posts)

  1. Hebbylaya
    Member
    Posted 3 months ago #

    I have a custom field setup called "youtubeid". One can insert the ID of a youtube video into it, then on my single.php page, it checks to see if that ID exists, then it inserts that ID into some embed code to put the youtube video into the post. This works nicely for me because i can then also pull the thumbnail image of the video from youtube for my archives page. The video part works in every browser EXCEPT Internet explorer. Thumbnails work fine.

    I'm wondering if IE just doesn't like you putting php into video embedding code?

    This is what my code looks like to display the video.

    <?php $youtubeid = get_post_meta($post->ID, "youtubeid", true); ?>
    			<?php if($youtubeid !== '') { ?>
    				<div class="video_style">
    				<object type="application/x-shockwave-flash" style="width:425px; height:350px;" data="http://www.youtube.com/v/<?php 
    
    echo $youtubeid; ?>">
    					<param name="movie" value="http://www.youtube.com/v/<?php echo "youtubeid"; ?>" />
    				</object>
    				</div>
    			<?php } ?>

    Any thoughts on why IE won't display the video?

  2. Hebbylaya
    Member
    Posted 3 months ago #

    Oh I should also add, upon viewing the source in Internet explorer, it just shows this

    <div class="video_style">
    				<object type="application/x-shockwave-flash" style="width:425px; height:350px;" data="http://www.youtube.com/v/1UcfjMNMYWo">
    					<param name="movie" value="http://www.youtube.com/v/youtubeid" />
    				</object>
    				</div>

    For the param value it shows http://www.youtube.com/v/youtubeid I wonder if something is wrong with my php then?

  3. gavingear
    Member
    Posted 1 month ago #

    Yes, there was an error- here's the fixed code:

    <?php $youtubeid = get_post_meta($post->ID, "youtubeid", true); ?>
    			<?php if($youtubeid !== '') { ?>
    				<div class="video_style">
    				<object type="application/x-shockwave-flash" style="width:425px; height:350px;" data="http://www.youtube.com/v/<?php echo $youtubeid; ?>">
    					<param name="movie" value="http://www.youtube.com/v/<?php echo $youtubeid; ?>" />
    				</object>
    				</div>
    			<?php } ?>

Reply

You must log in to post.

About this Topic