Make WordPress Core


Ignore:
Timestamp:
12/30/2015 12:05:07 AM (9 years ago)
Author:
azaozz
Message:

Responsive images: add compatibility for versions < 2.7 when the full image path was stored in the metadata. Introduces _wp_get_attachment_relative_path() and uses it in wp_get_attachment_url().

Props dd32, SergeyBiryukov.
Fixes #35106 for trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r36094 r36120  
    48804880                $url = str_replace($uploads['basedir'], $uploads['baseurl'], $file);
    48814881            } elseif ( false !== strpos($file, 'wp-content/uploads') ) {
    4882                 $url = $uploads['baseurl'] . substr( $file, strpos($file, 'wp-content/uploads') + 18 );
     4882                // Get the directory name relative to the basedir (back compat for pre-2.7 uploads)
     4883                $url = trailingslashit( $uploads['baseurl'] . '/' . _wp_get_attachment_relative_path( $file ) ) . basename( $file );
    48834884            } else {
    48844885                // It's a newly-uploaded file, therefore $file is relative to the basedir.
Note: See TracChangeset for help on using the changeset viewer.