mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Image sideload and wp_upload_dir() fixes from noel. fixes #7342 for trunk
git-svn-id: http://svn.automattic.com/wordpress/trunk@8369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8f29cb96e7
commit
cdcd6ffdf6
@ -34,13 +34,14 @@ function press_it() {
|
||||
$content = $_REQUEST['content'];
|
||||
|
||||
foreach( (array) $_REQUEST['photo_src'] as $key => $image) {
|
||||
// escape quote for matching
|
||||
$quoted = preg_quote2($image);
|
||||
|
||||
|
||||
// see if files exist in content - we don't want to upload non-used selected files.
|
||||
if( strpos($_REQUEST['content'], $quoted) !== false ) {
|
||||
if( strpos($_REQUEST['content'], $image) !== false ) {
|
||||
$upload = media_sideload_image($image, $post_ID, $_REQUEST['photo_description'][$key]);
|
||||
|
||||
// Replace the POSTED content <img> with correct uploaded ones.
|
||||
// escape quote for matching
|
||||
$quoted = preg_quote2($image);
|
||||
if( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=(\"|\')'.$quoted.'(\2)([^>\/]*)\/*>/is', $upload, $content);
|
||||
}
|
||||
}
|
||||
|
@ -1489,9 +1489,9 @@ function wp_upload_dir( $time = NULL ) {
|
||||
|
||||
// $dir is absolute, $path is (maybe) relative to ABSPATH
|
||||
$dir = path_join( ABSPATH, $dir );
|
||||
|
||||
|
||||
if ( !$url = get_option( 'upload_url_path' ) ) {
|
||||
if ( empty($upload_path) )
|
||||
if ( empty($upload_path) or ( $upload_path == $dir ) )
|
||||
$url = WP_CONTENT_URL . '/uploads';
|
||||
else
|
||||
$url = trailingslashit( $siteurl ) . $upload_path;
|
||||
@ -1523,8 +1523,9 @@ function wp_upload_dir( $time = NULL ) {
|
||||
$message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $dir );
|
||||
return array( 'error' => $message );
|
||||
}
|
||||
|
||||
|
||||
$uploads = array( 'path' => $dir, 'url' => $url, 'subdir' => $subdir, 'basedir' => $bdir, 'baseurl' => $burl, 'error' => false );
|
||||
|
||||
return apply_filters( 'upload_dir', $uploads );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user