Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions BFI_Thumb.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ public static function thumb( $url, $params = array(), $single = true ) {
$upload_url = $upload_info['baseurl'];
$theme_url = get_template_directory_uri();
$theme_dir = get_template_directory();
$home_dir = ABSPATH;
$home_url = get_home_url();

// find the path of the image. Perform 2 checks:
// #1 check if the image is in the uploads folder
Expand All @@ -477,6 +479,16 @@ public static function thumb( $url, $params = array(), $single = true ) {
} else if ( strpos( $url, $theme_url ) !== false ) {
$rel_path = str_replace( $theme_url, '', $url );
$img_path = $theme_dir . $rel_path;

// #3 check the original path
} else {
$origin_file = str_replace($home_url, substr($home_dir, 0, -1), $url);
if (file_exists($origin_file) &&
strpos(mime_content_type($origin_file), 'image/') !== false)
{
$rel_path = str_replace( $home_url, '', $url );
$img_path = $home_dir . $rel_path;
}
}

// Fail if we can't find the image in our WP local directory
Expand Down