From 3bb4c336e8635dbfb3b7811545ce5c07d4bbc8b0 Mon Sep 17 00:00:00 2001 From: Matth_eu Date: Thu, 2 Jul 2015 11:37:00 +0200 Subject: [PATCH] handle preview thumbs with basic auth --- inc/class-mexp-resource-space-service.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/inc/class-mexp-resource-space-service.php b/inc/class-mexp-resource-space-service.php index 7f196fe..2b1fdf7 100644 --- a/inc/class-mexp-resource-space-service.php +++ b/inc/class-mexp-resource-space-service.php @@ -101,9 +101,20 @@ public function request( array $request ) { $item->set_date( $clean_data['date'] ); $item->set_date_format( $clean_data['date_format'] ); $item->set_id( $clean_data['id'] ); - $item->set_thumbnail( $clean_data['thumbnail'] ); $item->set_url( $clean_data['url'] ); + if ( defined( 'PJ_RESOURCE_SPACE_AUTHL' ) && defined( 'PJ_RESOURCE_SPACE_AUTHP' ) ) { + + $bits = parse_url( $clean_data['thumbnail'] ); + $search = $bits['scheme'] . '://'; + $replace = sprintf( '%s://%s:%s@', $bits['scheme'], PJ_RESOURCE_SPACE_AUTHL, PJ_RESOURCE_SPACE_AUTHP ); + + $clean_data['thumbnail'] = str_replace( $search, $replace, $clean_data['thumbnail'] ); + + } + + $item->set_thumbnail( $clean_data['thumbnail'] ); + $response->add_item( $item ); }