Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

need function to embed video and dynamically change height/width WordPress

  • SOLVED

I am using the wp options table to store a few video embed codes that are input by the user into a theme admin panel.

What I am after is having the ability to dynamically change the height and width parameters of the video for the user automatically.

Here is an example function that I am trying to modify to work:
http://pastebin.com/9ZmN6nYa

I call the function in my template like:

global $ctheme_options
echo admin_panel_video_embed('video='.$ctheme_options['panel_1_embed'].'&width=600&height=400');


The function above was originally designed to work when embedding a video into a posts custom field 'embed'. When calling it that way in a template it works properly.

My problem:
When I use the video= instead of the embed parameter, what is output on the front end is always messed up.

After digging around a lot, I believe it may have to do with the ereg_replace() function, although I am not sure, it's just a guess.

What I need:
Can someone either modify the function I have provided, or better yet, provide a simple function that will allow me to set the width and height of the video in my theme template like I am doing in the call above? (I don't need the part of code that deals with the posts custom field 'embed', prefer simply calling my video parameter in the theme)

thanks

Answers (3)

2010-10-20

Denzel Chia answers:

Hi,
Based on the above codes and functions you paste.
Please try this.

global $ctheme_options

$args = array(
'key'=>'embed',
'width'=>'600',
'height'=>'400',
'video'=>$ctheme_options['panel_1_embed']
);

echo admin_panel_video_embed($args);


Thanks


Denzel Chia comments:

There is something wrong with your embed code I think the flashvar is wrong.
The embed code for your flashvars in your option is wrong or your function that uses it is adding in or removing html character entities.

I used the embed code of first video embed and paste onto the second, changed the with and height and it is working, I attached the screenshot.