WordPress.org

Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/wp-admin/press-this.php

    r8332 r8552  
    3535
    3636            foreach( (array) $_REQUEST['photo_src'] as $key => $image) {
    37                 // escape quote for matching
    38                 $quoted = preg_quote2($image);
    39 
     37               
    4038                // see if files exist in content - we don't want to upload non-used selected files.
    41                 if( strpos($_REQUEST['content'], $quoted) !== false ) {
     39                if( strpos($_REQUEST['content'], $image) !== false ) {
    4240                    $upload = media_sideload_image($image, $post_ID, $_REQUEST['photo_description'][$key]);
     41                     
    4342                    // Replace the POSTED content <img> with correct uploaded ones.
     43                    // escape quote for matching
     44                    $quoted = preg_quote2($image);
    4445                    if( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=(\"|\')'.$quoted.'(\2)([^>\/]*)\/*>/is', $upload, $content);
    4546                }
     
    184185        $host = parse_url($uri);
    185186
    186         $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif)[^<>\'\"]*)(\2)([^>\/]*)\/*>/is';
     187        $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif))[^<>\'\"]*(\2)([^>\/]*)\/*>/is';
    187188        preg_match_all($pattern, $content, $matches);
    188 
     189       
    189190        if ( empty($matches[1]) ) return '';
    190191
    191192        $sources = array();
    192193        foreach ($matches[3] as $src) {
     194            // if no http in url
    193195            if(strpos($src, 'http') === false)
    194                 if(strpos($src, '../') === false && strpos($src, './') === false)
     196                // if it doesn't have a relative uri
     197                if( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === true)
    195198                    $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
    196199                else
    197                     $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src);
    198 
     200                    $src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src);
     201           
    199202            $sources[] = clean_url($src);
    200203        }
     
    247250
    248251    function pick(img, desc) {
    249         if (img) { 
    250             length = jQuery('.photolist input').length;
     252        if (img) {
     253            if('object' == typeof jQuery('.photolist input') && jQuery('.photolist input').length != 0) length = jQuery('.photolist input').length;
    251254            if(length == 0) length = 1;
    252255            jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>');
    253256            jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>');
    254             append_editor("\n\n" + '<p><img src="' + img +'" alt="' + desc + '" /></p>');
     257            append_editor("\n\n" + '<p><img src="' + img +'" alt="' + desc + '" class="aligncenter"/></p>');
    255258        }
    256259        tinyMCE.activeEditor.resizeToContent();
     
    267270
    268271    jQuery(document).ready(function() {
     272        jQuery('#extra_fields').html('<div class="photolist"></div><small id="photo_directions"><?php _e("Click images to select:") ?> <span><a href="#" id="photo_add_url" class="thickbox"><?php _e("Add from URL") ?> +</a></span></small><div class="titlewrap"><div id="img_container"></div></div>');
    269273        jQuery('#img_container').html(strtoappend);
    270274        jQuery('#photo_add_url').attr('href', '?ajax=thickbox_url&height=200&width=500');
     
    276280
    277281if($_REQUEST['ajax'] == 'photo') { ?>
    278         <div class="photolist"></div>
    279 
    280         <small id="photo_directions"><?php _e('Click images to select:') ?> <span><a href="#" id="photo_add_url" class="thickbox"><?php _e('Add from URL') ?> +</a></span></small>
    281 
    282         <div class="titlewrap">
    283             <div id="img_container"></div>
    284         </div>
     282
    285283<?php die;
    286284}
     
    323321                language : "<?php echo $language; ?>",
    324322                width: "100%",
     323                height: "300",
    325324                theme : "advanced",
    326325                theme_advanced_buttons1 : "bold,italic,underline,blockquote,separator,strikethrough,bullist,numlist,undo,redo,link,unlink",
     
    446445                jQuery('#extra_fields').show();
    447446                jQuery('#extra_fields').before('<h2 id="waiting"><img src="images/loading.gif" alt="" /><?php echo js_escape( __( 'Loading...' ) ); ?></h2>');
    448                 jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']).'/?ajax=photo&u='.attribute_escape($url); ?>');
    449447                jQuery.ajax({
    450448                    type: "GET",
     
    473471        <?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?>
    474472            show('video');
    475             <?php  } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>
     473        <?php  } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>
    476474            show('photo');
    477475        <?php } ?>
     
    506504            <h2 id="content_type"><label for="content"><?php _e('Post') ?></label></h2>
    507505            <div class="editor-container">
    508                 <textarea name="content" id="content" style="width:100%;" class="mceEditor"><?php if ($selection) { echo wp_richedit_pre($selection); } ?><a href="<?php echo $url ?>"><?php echo $title; ?></a>.</textarea>
     506                <textarea name="content" id="content" style="width:100%;" class="mceEditor" rows="15"><?php if ($selection) { echo wp_richedit_pre($selection); } ?><a href="<?php echo $url ?>"><?php echo $title; ?></a>.</textarea>
    509507            </div>
    510508        </div>
Note: See TracChangeset for help on using the changeset viewer.