AyushSaran.com

Graphic Design Web Design San Diego

   

1

Jun

Allow Users to add Image/Videos in comments

This is a wordpress hack which will allow your users to add images and videos in comments.


Wordpress strips out most HTML tags for non-admin users. This leaves comments with text-only.But what if you want to run a contest for the funniest image/video etc….. something where you want users to be able to embed rich media in the comments instead of a text link




Step One - Locate your kses.php file


This can be found under /wp-includes/kses.php
Make a backup of this file - incase you need to revert to original


open the file in a text editor, Notepad or TextEdit(Mac) will do just fine


Around line 25 you will see html tags commented out using the // system


'strike' => array (), 'strong' => array (),
// 'sub' => array(),
// 'sup' => array(),



tags not commented are allowed, commented tags are NOT


we can add tags to this list to allow rich media but we also have to allow the attributes


To allow images add these lines after // 'ul' => array(), but before );

‘img’ => array (’alt’ => array (), ‘align’ => array (), ‘border’ => array (), ‘height’ => array (), ‘hspace’ => array (), ‘longdesc’ => array (), ‘vspace’ => array (), ’src’ => array ()),



This will allow image tags to be embedded in comments
To allow Youtube Videos add these lines

‘embed’ => array (’src’ => array (), ‘type’ => array (), ‘wmode’ => array (), ‘height’ => array (), ‘width’ => array ()),
‘object’ => array (’src’ => array (), ‘type’ => array (), ‘wmode’ => array (), ‘height’ => array (), ‘width’ => array ()),
‘param’ => array (’name’ => array (), ‘value’ => array (), ‘wmode’ => array (), ‘height’ => array (), ‘width’ => array ()),


This approach can be modified to allow videos from any site as long as you add the right Tags and Attributes


One Response to “Allow Users to add Image/Videos in comments”

Add Comment   Leave a Comment

You must be logged in to post a comment.