Delete [img] tags from quoted posts
#1
Pretty simple I think; I'd like to make it so that when someone selects to quote a post, any img tags in the post are stripped out.
Reply
#2
css:

blockquote img a,blockquote img{display:none}
Reply
#3
I'd rather strip it from the input when the post is quoted -- so that an img can be manually inserted into a quote if necessary -- but this is helpful if it can't happen, thanks.
Reply
#4
<?php

if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

/**
 * Plugin info
 *
 */
function dont_quote_images_info()
{
	return array(
				"name" => "Dont Quote Images",
				"description" => "",
				"website" => "",
				"author" => "Santiago Dimattia",
				"authorsite" => "http://www.teleportz.com.ar",
				"version" => "0.1",
				"guid" => "",
				"compatibility" => "16*"
			);
}

/**
 * Hook functions
 *
 */
$plugins->add_hook('newreply_end', 'dont_quote_images_do');

/**
 * Delete :)
 *
 */
function dont_quote_images_do()
{
	global $mybb, $message;

	if(isset($mybb->input['pid']))
	{
		$message = preg_replace("#\[img\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#ise", "", $message);
	}
}

As far as I can tell, it works OK.
Reply
#5
where do you place this?
Reply
#6
(2011-02-08, 08:35 PM)Uncontrol Wrote: where do you place this?

It's a plugin. Save the code as dont_quote_images.php and upload it to the plugins folder.
Reply
#7
This user has been denied support. This user has been denied support.
no ending parameters. correct code

<?php

if(!defined("IN_MYBB"))
{
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

/**
 * Plugin info
 *
 */
function dont_quote_images_info()
{
    return array(
                "name" => "Dont Quote Images",
                "description" => "",
                "website" => "",
                "author" => "Santiago Dimattia",
                "authorsite" => "http://www.teleportz.com.ar",
                "version" => "0.1",
                "guid" => "",
                "compatibility" => "16*"
            );
}

/**
 * Hook functions
 *
 */
$plugins->add_hook('newreply_end', 'dont_quote_images_do');

/**
 * Delete :)
 *
 */
function dont_quote_images_do()
{
    global $mybb, $message;

    if(isset($mybb->input['pid']))
    {
        $message = preg_replace("#\[img\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#ise", "", $message);
    }
}
?> 
MyPlugins:1-2-3-4-5
MyTutorials:AddBots
Reply
#8
(2011-02-08, 10:15 PM)TheGodFather Wrote: no ending parameters. correct code

<?php

if(!defined("IN_MYBB"))
{
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

/**
 * Plugin info
 *
 */
function dont_quote_images_info()
{
    return array(
                "name" => "Dont Quote Images",
                "description" => "",
                "website" => "",
                "author" => "Santiago Dimattia",
                "authorsite" => "http://www.teleportz.com.ar",
                "version" => "0.1",
                "guid" => "",
                "compatibility" => "16*"
            );
}

/**
 * Hook functions
 *
 */
$plugins->add_hook('newreply_end', 'dont_quote_images_do');

/**
 * Delete :)
 *
 */
function dont_quote_images_do()
{
    global $mybb, $message;

    if(isset($mybb->input['pid']))
    {
        $message = preg_replace("#\[img\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#ise", "", $message);
    }
}
?> 

It's not required to close the PHP tags.
In fact, it's recommended not to close them, as it prevents whitespaces at the end of the file (causing headers not being sent to the browser).

---

If you do close the tag, double-check if there is a whitespace or a linebreak at the end of the file before saving.
Reply
#9
I suggest not delete img tags, but replace with image links.
How to do that? Wink
Hello, Welcome to MyBB Indonesia to get local support
My 'Simple' Unique Plugin here Smile
Reply
#10
This should work:

$message = preg_replace("#\[img\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#ise", "\(Image: $2)\n", $message);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)