# Use customizer to select/edit a video

**URL:** https://forum.pinegrow.com/t/use-customizer-to-select-edit-a-video/4731
**Category:** Beginners
**Tags:** wordpress
**Created:** [November 28, 2020, 11:10pm UTC](https://forum.pinegrow.com/t/use-customizer-to-select-edit-a-video/4731 "2020-11-28T23:10:58Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![red-rosefields](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/red-rosefields/32/5392_2.png) [@red-rosefields](https://forum.pinegrow.com/u/red-rosefields)
#### Post date: [November 28, 2020, 11:10pm UTC](https://forum.pinegrow.com/t/use-customizer-to-select-edit-a-video/4731/1 "2020-11-28T23:10:58Z")

</div>

Hi All,  
Any idea on how to make a video editable in the customizer just as the image element. I have a div with a video in it (html5) and I need the capability to change edit this field and choosing another video. Just like you can change and image or a background image. Maybe with the src attribute…  
Any idea?  
Thanks all

---

<div class="post-metadata">

### Author: ![RobM](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@RobM](https://forum.pinegrow.com/u/RobM)
#### Post date: [November 29, 2020, 1:38pm UTC](https://forum.pinegrow.com/t/use-customizer-to-select-edit-a-video/4731/2 "2020-11-29T13:38:43Z")

</div>

Hi @red-rosefields,  
There isn’t currently a smart action for changing a video, as far as I know.  
The way I would do it is to create a container for the video. In PG you can add a video in and set it to not export with the WP actions.  
Then on the container you can set-up your customizer control like normal with a control type of media and a mime type of video. Since this will return an attachment id you can sanitize with ‘absint’.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/8/85e4392910d6d9322830b1f24d3b1ac921215879.png)  
Next, you will have to add in a block of PHP code inside the container

```auto
<?php
    $id = get_theme_mod('video_control');
    $attr = array( 'src' => wp_get_attachment_url( $id ) );
    echo wp_video_shortcode( $attr );
?>

```

Note: I used ‘video\_control’ as the id for my customizer control. If you change that id you will have to change it in the PHP block as well. Here is the whole thing.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/c/c771e4961416850bd04a8f25ca97c9db6c6ae234.png)  
Hope this answers your question!  
Bob

---

<div class="post-metadata">

### Author: ![red-rosefields](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/red-rosefields/32/5392_2.png) [@red-rosefields](https://forum.pinegrow.com/u/red-rosefields)
#### Post date: [November 29, 2020, 8:31pm UTC](https://forum.pinegrow.com/t/use-customizer-to-select-edit-a-video/4731/3 "2020-11-29T20:31:31Z")

</div>

Thanks RobM! i just tried but getting this error.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/e/e75d8079f46552884885212b845ffca53781324a.png)

Going to retry from scratch.  
Thanks for now.

---

<div class="post-metadata">

### Author: ![RobM](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@RobM](https://forum.pinegrow.com/u/RobM)
#### Post date: [November 29, 2020, 9:04pm UTC](https://forum.pinegrow.com/t/use-customizer-to-select-edit-a-video/4731/4 "2020-11-29T21:04:37Z")

</div>

Not sure what is going on with the error. What is ‘cb-main.js’? Is the video that you are trying to bring in wrapped in some type of jQuery loader? If so, maybe your’cb-main.js’ is being loaded before jQuery?

Can you share a screen shot of your customizer/video container so I can take a look?  
Thanks,  
Bob

---

<div class="post-metadata">

### Author: ![red-rosefields](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/red-rosefields/32/5392_2.png) [@red-rosefields](https://forum.pinegrow.com/u/red-rosefields)
#### Post date: [November 29, 2020, 9:40pm UTC](https://forum.pinegrow.com/t/use-customizer-to-select-edit-a-video/4731/5 "2020-11-29T21:40:48Z")

</div>

cb-main.js is this chockablock that I tried but never used it. I just deleted the script.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/0/0758e87b6bd7097922c25fa57ea30b2e87823a80.png)  
Thanks for looking.

---

<div class="post-metadata">

### Author: ![RobM](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@RobM](https://forum.pinegrow.com/u/RobM)
#### Post date: [November 30, 2020, 9:56am UTC](https://forum.pinegrow.com/t/use-customizer-to-select-edit-a-video/4731/6 "2020-11-30T09:56:01Z")

</div>

For the control block the sanitize callback should be ‘absint’ - absolute integer.  
Can you show the block of PHP code, as well?  
Thanks,  
Bob

---

<div class="post-metadata">

### Author: ![red-rosefields](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/red-rosefields/32/5392_2.png) [@red-rosefields](https://forum.pinegrow.com/u/red-rosefields)
#### Post date: [December 1, 2020, 8:22pm UTC](https://forum.pinegrow.com/t/use-customizer-to-select-edit-a-video/4731/7 "2020-12-01T20:22:40Z")

</div>

It worked! You just made my day easier!  
Many thanks man, appreciate the time you took on answering.  
cheers!

---

<div class="post-metadata">

### Author: ![Caseybarber](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/caseybarber/32/3146_2.png) [@Caseybarber](https://forum.pinegrow.com/u/Caseybarber)
#### Post date: [January 18, 2021, 11:23am UTC](https://forum.pinegrow.com/t/use-customizer-to-select-edit-a-video/4731/8 "2021-01-18T11:23:17Z")

</div>

Thanks for sharing, it has helped me reduce my time in editing work a lot
