Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hi! How do I insert youtube video in text editor field? That's blog section and I would like to be able to insert videos in my posts.
Hi,

To embed videos within the contents of an editable region (usually the richtext region), we can use 'shortcodes' -
https://docs.couchcms.com/miscellaneous/shortcodes.html. There is a sample shortcode for YouTube in the linked page.

You might also find Tim's 'universal' shortcode useful -
viewtopic.php?f=8&t=7950

Hope this helps.
I've tried tim's solution but it doesn't work.

Code: Select all
 // All-Purpose Embed Shortcode
   // Embed any code (almost).
   // Careful of your quotation mark types.
   // Won't accept the word "script."  No new lines. PHP code won't work.
   // Usage: [embed code='<p>Any code goes here.</p>']
   $FUNCS->register_shortcode( 'embed', 'embed_handler' );
   function embed_handler( $params, $content=null ){
      global $FUNCS;

      extract( $FUNCS->get_named_vars(array(
         'code' => '',
      ), $params) );

       // Pass on the code to Couch for execution using the 'embed' function
      return $FUNCS->embed( $code, $is_code=1 );
   }


I've add that code to kfunctions.php file.

The code for embedding YT video is:

Code: Select all
[embed code='<iframe width="560" height="315" src="https://www.youtube.com/embed/dww3Oo8ropA" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>']  


And everything I see on the frontend is that same code, there's no video.
Are you sure you have also used the <cms:do_shortcodes> tag in your template?
Please see the docs https://docs.couchcms.com/miscellaneous/shortcodes.html for this required 'Third' step in using shortcodes.
4 posts Page 1 of 1
cron