WordPress.org

Make WordPress Core

Changeset 8172


Ignore:
Timestamp:
06/23/08 21:16:39 (6 years ago)
Author:
ryan
Message:

Press This image linking fixes from noel. see #6813

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/media.php

    r8169 r8172  
    152152    if ( !is_wp_error($id) ) { 
    153153        wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); 
    154         return $src; 
    155     } 
    156      
     154        return $url; 
     155    } 
    157156    return $id; 
    158  
    159157} 
    160158 
     
    322320         
    323321        $id = media_handle_sideload($file_array, $post_id, $desc); 
     322        $src = $id; 
     323 
    324324        unset($file_array); 
    325          
     325 
    326326        if ( is_wp_error($id) ) { 
    327327            $errors['upload_error'] = $id; 
    328328            return $id; 
    329         } else { 
    330             $src = $id; 
    331         } 
    332     } 
    333      
    334     if (!empty($src) && !strpos($src, '://') ) { 
    335         $src = "http://$src"; 
     329        } 
     330    } 
     331 
     332    if ( !empty($src) ) { 
     333        if ( !strpos($src, '://') ) 
     334            $src = "http://$src"; 
    336335        $alt = @$desc; 
    337     } 
    338     if ( !empty($src) ) { 
    339336        $html = "<img src='$src' alt='$alt' />"; 
    340337        return $html; 
  • trunk/wp-admin/press-this.php

    r8169 r8172  
    55 
    66<?php  
     7 
     8function preg_quote2($string) { 
     9    return str_replace('/', '\/', preg_quote($string)); 
     10} 
    711function press_it() { 
    8     #define some basic variables 
     12    // define some basic variables 
    913    $quick['post_status'] = $_REQUEST['post_status']; 
    1014    $quick['post_category'] = $_REQUEST['post_category']; 
     
    1317    $quick['post_content'] = ''; 
    1418         
    15     # insert the post with nothing in it, to get an ID 
     19    // insert the post with nothing in it, to get an ID 
    1620    $post_ID = wp_insert_post($quick, true); 
    1721         
     
    2428         
    2529        case 'photo': 
    26             foreach($_REQUEST['photo_src'] as $key => $data) { 
     30            $content = $_REQUEST['content']; 
     31             
     32            foreach($_REQUEST['photo_src'] as $key => $image) { 
    2733                #quote for matching 
    28                 $quoted = str_replace('/', '\/', preg_quote($data)); 
     34                $quoted = preg_quote2($image); 
    2935                 
    30                 # see if files exist in content - we don't want to upload non-used selected files. 
     36                // see if files exist in content - we don't want to upload non-used selected files. 
    3137                preg_match('/'.$quoted.'/', $_REQUEST['content'], $matches[0]); 
    32                 if($matches[0]) 
    33                     $upload = media_sideload_image($data, $post_ID, $_REQUEST['photo_description'][$key]);   
     38                if($matches[0]) { 
     39                    $upload = media_sideload_image($image, $post_ID, $_REQUEST['photo_description'][$key]); 
     40                    // Replace the POSTED content <img> with correct uploaded ones. 
     41                    if( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=(\"|\')'.$quoted.'(\2)([^>\/]*)\/*>/is', $upload, $content); 
     42                } 
    3443            } 
    35             $content = $_REQUEST['content']; 
     44             
    3645            break; 
    3746             
Note: See TracChangeset for help on using the changeset viewer.