<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[11944] trunk/wp-admin: Press This fixes.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/11944">11944</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2009-09-17 20:36:59 +0000 (Thu, 17 Sep 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Press This fixes. Props noel. fixes <a href="http://trac.wordpress.org/ticket/10784">#10784</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesmediaphp">trunk/wp-admin/includes/media.php</a></li>
<li><a href="#trunkwpadminpressthisphp">trunk/wp-admin/press-this.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/media.php (11943 => 11944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/media.php        2009-09-17 20:17:33 UTC (rev 11943)
+++ trunk/wp-admin/includes/media.php        2009-09-17 20:36:59 UTC (rev 11944)
</span><span class="lines">@@ -249,8 +249,8 @@
</span><span class="cx">  */
</span><span class="cx"> function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) {
</span><span class="cx">         $overrides = array('test_form'=&gt;false);
</span><ins>+        
</ins><span class="cx">         $file = wp_handle_sideload($file_array, $overrides);
</span><del>-
</del><span class="cx">         if ( isset($file['error']) )
</span><span class="cx">                 return new WP_Error( 'upload_error', $file['error'] );
</span><span class="cx"> 
</span><span class="lines">@@ -279,7 +279,7 @@
</span><span class="cx">                 'post_content' =&gt; $content,
</span><span class="cx">         ), $post_data );
</span><span class="cx"> 
</span><del>-        // Save the data
</del><ins>+        // Save the attachment metadata
</ins><span class="cx">         $id = wp_insert_attachment($attachment, $file, $post_id);
</span><span class="cx">         if ( !is_wp_error($id) ) {
</span><span class="cx">                 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
</span><span class="lines">@@ -520,25 +520,33 @@
</span><span class="cx">  */
</span><span class="cx"> function media_sideload_image($file, $post_id, $desc = null) {
</span><span class="cx">         if (!empty($file) ) {
</span><del>-                $file_array['name'] = basename($file);
</del><ins>+                // Download file to temp location
</ins><span class="cx">                 $tmp = download_url($file);
</span><ins>+                
+                // Set variables for storage
+                // fix file filename for query strings
+                preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $file, $matches);
+                $file_array['name'] = basename($matches[0]);
</ins><span class="cx">                 $file_array['tmp_name'] = $tmp;
</span><del>-                $desc = @$desc;
</del><span class="cx"> 
</span><ins>+                // If error storing temporarily, unlink
</ins><span class="cx">                 if ( is_wp_error($tmp) ) {
</span><span class="cx">                         @unlink($file_array['tmp_name']);
</span><span class="cx">                         $file_array['tmp_name'] = '';
</span><span class="cx">                 }
</span><del>-
-                $id = media_handle_sideload($file_array, $post_id, $desc);
</del><ins>+                
+                // do the validation and storage stuff
+                $id = media_handle_sideload($file_array, $post_id, @$desc);
</ins><span class="cx">                 $src = $id;
</span><del>-
</del><ins>+                
+                // If error storing permanently, unlink
</ins><span class="cx">                 if ( is_wp_error($id) ) {
</span><span class="cx">                         @unlink($file_array['tmp_name']);
</span><span class="cx">                         return $id;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-
</del><ins>+        
+        // Finally check to make sure the file has been saved, then return the html
</ins><span class="cx">         if ( !empty($src) ) {
</span><span class="cx">                 $alt = @$desc;
</span><span class="cx">                 $html = &quot;&lt;img src='$src' alt='$alt' /&gt;&quot;;
</span></span></pre></div>
<a id="trunkwpadminpressthisphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/press-this.php (11943 => 11944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/press-this.php        2009-09-17 20:17:33 UTC (rev 11943)
+++ trunk/wp-admin/press-this.php        2009-09-17 20:36:59 UTC (rev 11944)
</span><span class="lines">@@ -42,29 +42,29 @@
</span><span class="cx"> function press_it() {
</span><span class="cx">         // define some basic variables
</span><span class="cx">         $quick['post_status'] = 'draft'; // set as draft first
</span><del>-        $quick['post_category'] = isset($_REQUEST['post_category']) ? $_REQUEST['post_category'] : null;
-        $quick['tax_input'] = isset($_REQUEST['tax_input']) ? $_REQUEST['tax_input'] : '';
-        $quick['post_title'] = isset($_REQUEST['title']) ? $_REQUEST['title'] : '';
</del><ins>+        $quick['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : null;
+        $quick['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : '';
+        $quick['post_title'] = isset($_POST['title']) ? $_POST['title'] : '';
</ins><span class="cx">         $quick['post_content'] = '';
</span><span class="cx"> 
</span><span class="cx">         // insert the post with nothing in it, to get an ID
</span><span class="cx">         $post_ID = wp_insert_post($quick, true);
</span><del>-        $content = isset($_REQUEST['content']) ? $_REQUEST['content'] : '';
</del><ins>+        $content = isset($_POST['content']) ? $_POST['content'] : '';
</ins><span class="cx"> 
</span><span class="cx">         $upload = false;
</span><del>-        if( !empty($_REQUEST['photo_src']) &amp;&amp; current_user_can('upload_files') )
-                foreach( (array) $_REQUEST['photo_src'] as $key =&gt; $image)
</del><ins>+        if( !empty($_POST['photo_src']) &amp;&amp; current_user_can('upload_files') )
+                foreach( (array) $_POST['photo_src'] as $key =&gt; $image)
</ins><span class="cx">                         // see if files exist in content - we don't want to upload non-used selected files.
</span><del>-                        if( strpos($_REQUEST['content'], $image) !== false ) {
-                                $desc = isset($_REQUEST['photo_description'][$key]) ? $_REQUEST['photo_description'][$key] : '';
</del><ins>+                        if( strpos($_POST['content'], htmlspecialchars($image)) !== false ) {
+                                $desc = isset($_POST['photo_description'][$key]) ? $_POST['photo_description'][$key] : '';
</ins><span class="cx">                                 $upload = media_sideload_image($image, $post_ID, $desc);
</span><span class="cx"> 
</span><span class="cx">                                 // Replace the POSTED content &lt;img&gt; with correct uploaded ones. Regex contains fix for Magic Quotes
</span><del>-                                if( !is_wp_error($upload) ) $content = preg_replace('/&lt;img ([^&gt;]*)src=\\\?(\&quot;|\')'.preg_quote($image, '/').'\\\?(\2)([^&gt;\/]*)\/*&gt;/is', $upload, $content);
</del><ins>+                                if( !is_wp_error($upload) ) $content = preg_replace('/&lt;img ([^&gt;]*)src=\\\?(\&quot;|\')'.preg_quote(htmlspecialchars($image), '/').'\\\?(\2)([^&gt;\/]*)\/*&gt;/is', $upload, $content);
</ins><span class="cx">                         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         // set the post_content and status
</span><del>-        $quick['post_status'] = isset($_REQUEST['publish']) ? 'publish' : 'draft';
</del><ins>+        $quick['post_status'] = isset($_POST['publish']) ? 'publish' : 'draft';
</ins><span class="cx">         $quick['post_content'] = $content;
</span><span class="cx">         // error handling for $post
</span><span class="cx">         if ( is_wp_error($post_ID)) {
</span><span class="lines">@@ -100,80 +100,86 @@
</span><span class="cx"> $url = isset($_GET['u']) ? esc_url($_GET['u']) : '';
</span><span class="cx"> $image = isset($_GET['i']) ? $_GET['i'] : '';
</span><span class="cx"> 
</span><del>-if ( !empty($_REQUEST['ajax']) ) {
-switch ($_REQUEST['ajax']) {
-        case 'video': ?&gt;
-                &lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
-                        jQuery('.select').click(function() {
-                                append_editor(jQuery('#embed-code').val());
-                                jQuery('#extra_fields').hide();
-                                jQuery('#extra_fields').html('');
-                        });
-                        jQuery('.close').click(function() {
-                                jQuery('#extra_fields').hide();
-                                jQuery('#extra_fields').html('');
-                        });
-                &lt;/script&gt;
-                &lt;div class=&quot;postbox&quot;&gt;
-                &lt;h2&gt;&lt;label for=&quot;embed-code&quot;&gt;&lt;?php _e('Embed Code') ?&gt;&lt;/label&gt;&lt;/h2&gt;
-                &lt;div class=&quot;inside&quot;&gt;
-                        &lt;textarea name=&quot;embed-code&quot; id=&quot;embed-code&quot; rows=&quot;8&quot; cols=&quot;40&quot;&gt;&lt;?php echo format_to_edit($selection, true); ?&gt;&lt;/textarea&gt;
-                        &lt;p id=&quot;options&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;select button&quot;&gt;&lt;?php _e('Insert Video'); ?&gt;&lt;/a&gt; &lt;a href=&quot;#&quot; class=&quot;close button&quot;&gt;&lt;?php _e('Cancel'); ?&gt;&lt;/a&gt;&lt;/p&gt;
-                &lt;/div&gt;
-                &lt;/div&gt;
-                &lt;?php break;
</del><ins>+if ( !empty($_GET['ajax']) ) {
+        switch ($_GET['ajax']) {
+                case 'video': ?&gt;
+                        &lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
+                        /* &lt;![CDATA[ */
+                                jQuery('.select').click(function() {
+                                        append_editor(jQuery('#embed-code').val());
+                                        jQuery('#extra_fields').hide();
+                                        jQuery('#extra_fields').html('');
+                                });
+                                jQuery('.close').click(function() {
+                                        jQuery('#extra_fields').hide();
+                                        jQuery('#extra_fields').html('');
+                                });
+                        /* ]]&gt; */
+                        &lt;/script&gt;
+                        &lt;div class=&quot;postbox&quot;&gt;
+                                &lt;h2&gt;&lt;label for=&quot;embed-code&quot;&gt;&lt;?php _e('Embed Code') ?&gt;&lt;/label&gt;&lt;/h2&gt;
+                                &lt;div class=&quot;inside&quot;&gt;
+                                        &lt;textarea name=&quot;embed-code&quot; id=&quot;embed-code&quot; rows=&quot;8&quot; cols=&quot;40&quot;&gt;&lt;?php echo format_to_edit($selection, true); ?&gt;&lt;/textarea&gt;
+                                        &lt;p id=&quot;options&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;select button&quot;&gt;&lt;?php _e('Insert Video'); ?&gt;&lt;/a&gt; &lt;a href=&quot;#&quot; class=&quot;close button&quot;&gt;&lt;?php _e('Cancel'); ?&gt;&lt;/a&gt;&lt;/p&gt;
+                                &lt;/div&gt;
+                        &lt;/div&gt;
+                        &lt;?php break;
</ins><span class="cx"> 
</span><del>-        case 'photo_thickbox': ?&gt;
-                &lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
-                        jQuery('.cancel').click(function() {
-                                tb_remove();
-                        });
-                        jQuery('.select').click(function() {
-                                image_selector();
-                        });
-                &lt;/script&gt;
-                &lt;h3 class=&quot;tb&quot;&gt;&lt;label for=&quot;this_photo_description&quot;&gt;&lt;?php _e('Description') ?&gt;&lt;/label&gt;&lt;/h3&gt;
-                &lt;div class=&quot;titlediv&quot;&gt;
-                &lt;div class=&quot;titlewrap&quot;&gt;
-                        &lt;input id=&quot;this_photo_description&quot; name=&quot;photo_description&quot; class=&quot;tbtitle text&quot; onkeypress=&quot;if(event.keyCode==13) image_selector();&quot; value=&quot;&lt;?php echo esc_attr($title);?&gt;&quot;/&gt;
-                &lt;/div&gt;
-                &lt;/div&gt;
</del><ins>+                case 'photo_thickbox': ?&gt;
+                        &lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
+                                /* &lt;![CDATA[ */
+                                jQuery('.cancel').click(function() {
+                                        tb_remove();
+                                });
+                                jQuery('.select').click(function() {
+                                        image_selector();
+                                });
+                                /* ]]&gt; */
+                        &lt;/script&gt;
+                        &lt;h3 class=&quot;tb&quot;&gt;&lt;label for=&quot;this_photo_description&quot;&gt;&lt;?php _e('Description') ?&gt;&lt;/label&gt;&lt;/h3&gt;
+                        &lt;div class=&quot;titlediv&quot;&gt;
+                                &lt;div class=&quot;titlewrap&quot;&gt;
+                                        &lt;input id=&quot;this_photo_description&quot; name=&quot;photo_description&quot; class=&quot;tbtitle text&quot; onkeypress=&quot;if(event.keyCode==13) image_selector();&quot; value=&quot;&lt;?php echo esc_attr($title);?&gt;&quot;/&gt;
+                                &lt;/div&gt;
+                        &lt;/div&gt;
</ins><span class="cx"> 
</span><del>-                &lt;p class=&quot;centered&quot;&gt;&lt;input type=&quot;hidden&quot; name=&quot;this_photo&quot; value=&quot;&lt;?php echo esc_attr($image); ?&gt;&quot; id=&quot;this_photo&quot; /&gt;
-                        &lt;a href=&quot;#&quot; class=&quot;select&quot;&gt;&lt;img src=&quot;&lt;?php echo esc_url($image); ?&gt;&quot; alt=&quot;&lt;?php echo esc_attr(__('Click to insert.')); ?&gt;&quot; title=&quot;&lt;?php echo esc_attr(__('Click to insert.')); ?&gt;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</del><ins>+                        &lt;p class=&quot;centered&quot;&gt;
+                                &lt;input type=&quot;hidden&quot; name=&quot;this_photo&quot; value=&quot;&lt;?php echo esc_attr($image); ?&gt;&quot; id=&quot;this_photo&quot; /&gt;
+                                &lt;a href=&quot;#&quot; class=&quot;select&quot;&gt;
+                                        &lt;img src=&quot;&lt;?php echo esc_url($image); ?&gt;&quot; alt=&quot;&lt;?php echo esc_attr(__('Click to insert.')); ?&gt;&quot; title=&quot;&lt;?php echo esc_attr(__('Click to insert.')); ?&gt;&quot; /&gt;
+                                &lt;/a&gt;
+                        &lt;/p&gt;
</ins><span class="cx"> 
</span><del>-                &lt;p id=&quot;options&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;select button&quot;&gt;&lt;?php _e('Insert Image'); ?&gt;&lt;/a&gt; &lt;a href=&quot;#&quot; class=&quot;cancel button&quot;&gt;&lt;?php _e('Cancel'); ?&gt;&lt;/a&gt;&lt;/p&gt;
</del><ins>+                        &lt;p id=&quot;options&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;select button&quot;&gt;&lt;?php _e('Insert Image'); ?&gt;&lt;/a&gt; &lt;a href=&quot;#&quot; class=&quot;cancel button&quot;&gt;&lt;?php _e('Cancel'); ?&gt;&lt;/a&gt;&lt;/p&gt;
+                        &lt;?php break;
</ins><span class="cx"> 
</span><ins>+                case 'photo_thickbox_url': ?&gt;
+                        &lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
+                                /* &lt;![CDATA[ */
+                                jQuery('.cancel').click(function() {
+                                        tb_remove();
+                                });
</ins><span class="cx"> 
</span><del>-                &lt;?php break;
-
-        case 'photo_thickbox_url': ?&gt;
-                &lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
-                        jQuery('.cancel').click(function() {
-                                tb_remove();
-                        });
-
-                        jQuery('.select').click(function() {
-                                image_selector();
-                        });
-                &lt;/script&gt;
-                &lt;h3 class=&quot;tb&quot;&gt;&lt;label for=&quot;this_photo&quot;&gt;&lt;?php _e('URL') ?&gt;&lt;/label&gt;&lt;/h3&gt;
-                &lt;div class=&quot;titlediv&quot;&gt;
-                        &lt;div class=&quot;titlewrap&quot;&gt;
-                        &lt;input id=&quot;this_photo&quot; name=&quot;this_photo&quot; class=&quot;tbtitle text&quot; onkeypress=&quot;if(event.keyCode==13) image_selector();&quot; /&gt;
</del><ins>+                                jQuery('.select').click(function() {
+                                        image_selector();
+                                });
+                                /* ]]&gt; */
+                        &lt;/script&gt;
+                        &lt;h3 class=&quot;tb&quot;&gt;&lt;label for=&quot;this_photo&quot;&gt;&lt;?php _e('URL') ?&gt;&lt;/label&gt;&lt;/h3&gt;
+                        &lt;div class=&quot;titlediv&quot;&gt;
+                                &lt;div class=&quot;titlewrap&quot;&gt;
+                                        &lt;input id=&quot;this_photo&quot; name=&quot;this_photo&quot; class=&quot;tbtitle text&quot; onkeypress=&quot;if(event.keyCode==13) image_selector();&quot; /&gt;
+                                &lt;/div&gt;
</ins><span class="cx">                         &lt;/div&gt;
</span><del>-                &lt;/div&gt;
-
-
-                &lt;h3 class=&quot;tb&quot;&gt;&lt;label for=&quot;photo_description&quot;&gt;&lt;?php _e('Description') ?&gt;&lt;/label&gt;&lt;/h3&gt;
-                &lt;div id=&quot;titlediv&quot;&gt;
-                        &lt;div class=&quot;titlewrap&quot;&gt;
-                        &lt;input id=&quot;this_photo_description&quot; name=&quot;photo_description&quot; class=&quot;tbtitle text&quot; onkeypress=&quot;if(event.keyCode==13) image_selector();&quot; value=&quot;&lt;?php echo esc_attr($title);?&gt;&quot;/&gt;
</del><ins>+                        &lt;h3 class=&quot;tb&quot;&gt;&lt;label for=&quot;photo_description&quot;&gt;&lt;?php _e('Description') ?&gt;&lt;/label&gt;&lt;/h3&gt;
+                        &lt;div id=&quot;titlediv&quot;&gt;
+                                &lt;div class=&quot;titlewrap&quot;&gt;
+                                        &lt;input id=&quot;this_photo_description&quot; name=&quot;photo_description&quot; class=&quot;tbtitle text&quot; onkeypress=&quot;if(event.keyCode==13) image_selector();&quot; value=&quot;&lt;?php echo esc_attr($title);?&gt;&quot;/&gt;
+                                &lt;/div&gt;
</ins><span class="cx">                         &lt;/div&gt;
</span><del>-                &lt;/div&gt;
</del><span class="cx"> 
</span><del>-                &lt;p id=&quot;options&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;select&quot;&gt;&lt;?php _e('Insert Image'); ?&gt;&lt;/a&gt; | &lt;a href=&quot;#&quot; class=&quot;cancel&quot;&gt;&lt;?php _e('Cancel'); ?&gt;&lt;/a&gt;&lt;/p&gt;
-                &lt;?php break;
</del><ins>+                        &lt;p id=&quot;options&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;select&quot;&gt;&lt;?php _e('Insert Image'); ?&gt;&lt;/a&gt; | &lt;a href=&quot;#&quot; class=&quot;cancel&quot;&gt;&lt;?php _e('Cancel'); ?&gt;&lt;/a&gt;&lt;/p&gt;
+                        &lt;?php break;
</ins><span class="cx">         case 'photo_images':
</span><span class="cx">                 /**
</span><span class="cx">                  * Retrieve all image URLs from given URI.
</span><span class="lines">@@ -186,13 +192,13 @@
</span><span class="cx">                  * @return string
</span><span class="cx">                  */
</span><span class="cx">                 function get_images_from_uri($uri) {
</span><del>-                        if( preg_match('/\.(jpg|jpe|jpeg|png|gif)$/', $uri) &amp;&amp; !strpos($uri,'blogger.com') )
-                                return &quot;'&quot;.$uri.&quot;'&quot;;
</del><ins>+                        if( preg_match('/\.(jpg|jpe|jpeg|png|gif)/', $uri) &amp;&amp; !strpos($uri,'blogger.com') )
+                                return &quot;'&quot;.html_entity_decode($uri).&quot;'&quot;;
</ins><span class="cx">                         $content = wp_remote_fopen($uri);
</span><span class="cx">                         if ( false === $content )
</span><span class="cx">                                 return '';
</span><span class="cx">                         $host = parse_url($uri);
</span><del>-                        $pattern = '/&lt;img ([^&gt;]*)src=(\&quot;|\')([^&lt;&gt;]+?\.(png|jpeg|jpg|jpe|gif))[^&lt;&gt;\'\&quot;]*(\2)([^&gt;\/]*)\/*&gt;/is';
</del><ins>+                        $pattern = '/&lt;img ([^&gt;]*)src=(\&quot;|\')([^&lt;&gt;]+?\.(png|jpeg|jpg|jpe|gif)[^&lt;&gt;\'\&quot;]*)(\2)([^&gt;\/]*)\/*&gt;/is';
</ins><span class="cx">                         preg_match_all($pattern, $content, $matches);
</span><span class="cx">                         if ( empty($matches[0]) )
</span><span class="cx">                                 return '';
</span><span class="lines">@@ -210,7 +216,6 @@
</span><span class="cx">                         return &quot;'&quot; . implode(&quot;','&quot;, $sources) . &quot;'&quot;;
</span><span class="cx">                 }
</span><span class="cx">                 $url = urldecode($url);
</span><del>-                $url = str_replace(' ', '%20', $url);
</del><span class="cx">                 echo 'new Array('.get_images_from_uri($url).')';
</span><span class="cx"> 
</span><span class="cx">                 break;
</span><span class="lines">@@ -219,31 +224,31 @@
</span><span class="cx">                 // gather images and load some default JS
</span><span class="cx">                 var last = null
</span><span class="cx">                 var img, img_tag, aspect, w, h, skip, i, strtoappend = &quot;&quot;;
</span><ins>+                var my_src = eval(
+                        jQuery.ajax({
+                                   type: &quot;GET&quot;,
+                                   url: &quot;&lt;?php echo esc_url($_SERVER['PHP_SELF']); ?&gt;&quot;,
+                                cache : false,
+                                async : false,
+                                   data: &quot;ajax=photo_images&amp;u=&lt;?php echo urlencode($url); ?&gt;&quot;,
+                                dataType : &quot;script&quot;
+                        }).responseText
+                );
+                if(my_src.length == 0) {
</ins><span class="cx">                         var my_src = eval(
</span><span class="cx">                                 jQuery.ajax({
</span><del>-                                           type: &quot;GET&quot;,
-                                           url: &quot;&lt;?php echo esc_url($_SERVER['PHP_SELF']); ?&gt;&quot;,
</del><ins>+                                           type: &quot;GET&quot;,
+                                           url: &quot;&lt;?php echo esc_url($_SERVER['PHP_SELF']); ?&gt;&quot;,
</ins><span class="cx">                                         cache : false,
</span><span class="cx">                                         async : false,
</span><del>-                                           data: &quot;ajax=photo_images&amp;u=&lt;?php echo urlencode($url); ?&gt;&quot;,
</del><ins>+                                           data: &quot;ajax=photo_images&amp;u=&lt;?php echo urlencode($url); ?&gt;&quot;,
</ins><span class="cx">                                         dataType : &quot;script&quot;
</span><span class="cx">                                 }).responseText
</span><span class="cx">                         );
</span><span class="cx">                         if(my_src.length == 0) {
</span><del>-                                var my_src = eval(
-                                jQuery.ajax({
-                                           type: &quot;GET&quot;,
-                                           url: &quot;&lt;?php echo esc_url($_SERVER['PHP_SELF']); ?&gt;&quot;,
-                                        cache : false,
-                                        async : false,
-                                           data: &quot;ajax=photo_images&amp;u=&lt;?php echo urlencode($url); ?&gt;&quot;,
-                                        dataType : &quot;script&quot;
-                                }).responseText
-                                );
-                                if(my_src.length == 0) {
-                                        strtoappend = '&lt;?php _e('Unable to retrieve images or no images on page.'); ?&gt;';
-                                }
</del><ins>+                                strtoappend = '&lt;?php _e('Unable to retrieve images or no images on page.'); ?&gt;';
</ins><span class="cx">                         }
</span><ins>+                }
</ins><span class="cx"> 
</span><span class="cx">                 for (i = 0; i &lt; my_src.length; i++) {
</span><span class="cx">                         img = new Image();
</span></span></pre>
</div>
</div>

</body>
</html>