mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Make attachment file path relative to the upload dir. Don't use GUID to find attachement URL. Props DD32. see #7622
git-svn-id: https://develop.svn.wordpress.org/trunk@8796 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -93,6 +93,13 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
||||
$metadata['height'] = $imagesize[1];
|
||||
list($uwidth, $uheight) = wp_shrink_dimensions($metadata['width'], $metadata['height']);
|
||||
$metadata['hwstring_small'] = "height='$uheight' width='$uwidth'";
|
||||
// Make the file path relative to the upload dir
|
||||
if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { // Get upload directory
|
||||
if ( 0 === strpos($file, $uploads['basedir']) ) {// Check that the upload base exists in the file path
|
||||
$file = str_replace($uploads['basedir'], '', $file); // Remove upload dir from the file path
|
||||
$file = ltrim($file, '/');
|
||||
}
|
||||
}
|
||||
$metadata['file'] = $file;
|
||||
|
||||
// make thumbnails and other intermediate sizes
|
||||
|
||||
Reference in New Issue
Block a user