Welcome! » Log In » Create A New Profile

External Images, Remote Images, Munge Resources Help

Posted by Everwebby 
External Images, Remote Images, Munge Resources Help
January 27, 2012 09:58AM

I am having the hardest time with MungeResources and the utilization of external images in a safe manner. I have been trying to figure for some time now, any help with this would be appreciated.

To clarify, I am looking to do this:

user inputs : img src='http://www.theirsite.com/headshot.gif'

and I want this to happen:

img src='http://img.mysite.com/img.php?p=http://www.theirsite.com/headshot.gif'

or something to that effect. What would be perfect is to automatically download it and store on my server.

img src='http://img.mysite.com/img.php?p=http://www.theirsite.com/headshot.gif'

That and the other problem is when I purifier the document, I could take the purified code and it fails the WC3 validation. Any help would be appreciated as this project is taking too long already.

Here is my setup:

require_once '../htmlpurifier-4-3lte/library/HTMLPurifier.auto.php';

$config = HTMLPurifier_Config::createDefault();

$config->set('Core.Encoding', 'UTF-8');

$config->set('HTML.Doctype', 'HTML 4.01 Transitional');

$config->set('HTML.TidyLevel', 'heavy');

$config->set('URI.Base', 'http://www.mysite.com');

$config->set('URI.MakeAbsolute', true);

$config->set('AutoFormat.AutoParagraph', true);

$config->set('URI.MungeResources', true);

$config->set('URI.Munge', 'http://www.google.com/url?q=%s');

$config->set('HTML.Allowed', 'u,p,b,i,p,strong,em,li,ul,ol,div[align],br,img,img[src],a,a[href]');

$config->set('AutoFormat.Linkify', true);

$purifier = new HTMLPurifier();

Re: External Images, Remote Images, Munge Resources Help
January 27, 2012 07:28PM

I don't understand. What's the problem?

Author:
Your Email:

Subject:

HTML input is enabled. Make sure you escape all HTML and angled brackets with < and >.

Auto-paragraphing is enabled. Double newlines will be converted to paragraphs; for single newlines, use the pre tag.

Allowed tags: a, abbr, acronym, b, blockquote, caption, cite, code, dd, del, dfn, div, dl, dt, em, i, ins, kbd, li, ol, p, pre, s, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var.

For inputting literal code such as HTML and PHP for display, use CDATA tags to auto-escape your angled brackets, and pre to preserve newlines:

<pre><![CDATA[
Place code here
]]></pre>

Power users, you can hide this notice with:

.htmlpurifier-help {display:none;}

Message: