Make WordPress Core


Ignore:
Timestamp:
09/02/2008 10:55:39 PM (18 years ago)
Author:
ryan
Message:

Make attachment file path relative to the upload dir. Don't use GUID to find attachement URL. Props DD32. see #7622

File:
1 edited

Legend:

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

    r8744 r8796  
    9494                list($uwidth, $uheight) = wp_shrink_dimensions($metadata['width'], $metadata['height']);
    9595                $metadata['hwstring_small'] = "height='$uheight' width='$uwidth'";
     96                // Make the file path relative to the upload dir
     97                if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { // Get upload directory
     98                        if ( 0 === strpos($file, $uploads['basedir']) ) {// Check that the upload base exists in the file path
     99                                $file = str_replace($uploads['basedir'], '', $file); // Remove upload dir from the file path
     100                                $file = ltrim($file, '/');
     101                        }
     102                }
    96103                $metadata['file'] = $file;
    97104
Note: See TracChangeset for help on using the changeset viewer.