Skip to content

Commit

Permalink
Merge pull request humanmade#3 from humanmade/fix-basic-auth-thumbs
Browse files Browse the repository at this point in the history
handle preview thumbs with basic auth
  • Loading branch information
mattheu committed Jul 2, 2015
2 parents 54b4c68 + 3bb4c33 commit f50efb7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion inc/class-mexp-resource-space-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

}
Expand Down

0 comments on commit f50efb7

Please sign in to comment.