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:
Ryan Boren
2008-09-02 22:55:39 +00:00
parent ef05077a3b
commit 9045798e95
2 changed files with 32 additions and 2 deletions

View File

@@ -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