Embedding local video in Wordpress comments

I'm trying to embed a video file (from Media Library) in a comment.

Adding the default code currently used in Posts didn't work:

[video width=1280 height=718 mp4=https://www.example.com/wp-content/uploads/2021/10/video.mp4][/video]

Pasting the raw link in the comment dind't work either, and the output was in plain text:

[video src=https://www.example.com/wp-content/uploads/2021/10/video.mp4 /]

Is there a way to make Wordpress parse the comments in a way that I can use either the video shortcode or the raw link? I'm asking for help because I don't want to use a plugin for this. Thanks.

Topic video-player embed comments Wordpress

Category Web


Yea, you can't use short codes in comments by default with WordPress. Short codes are anything surrounded in those '[ ]' brackets. There are plugins you can install that allow you to use short-codes in posts, products, categories, and other places in WordPress that you aren't able to by default. However, I don't know of any that will allow you to put short-codes inside of comments fields since those fields are usually reserved for users to fill out.

There is a way to add your own PHP code to functions.php to add this ability as explained in this article: https://www.isitwp.com/add-shortcode-support-to-comments/

The other option would be to try using the HTML5 tag for videos, . Which would look something like:

<video controls width="250">
  <source src="/uploads/flower.webm" type="video/webm">
  <source src="/uploads/flower.mp4" type="video/mp4">
  <source src="/uploads/flower.ogg" type="video/ogg">
</video>

Although, with the tag option, you may run into compatibility issues with different browsers & Operating Systems. If you do decide to try this option, just make sure that you include a few different video formats like the 3 I included (mp4, webm, & ogg) to increase the chances the video will be compatible and viewable for most people.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.