-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Currently Tonesque doesn't work with remote images when running in environments where allow_url_fopen is disabled because it uses the imagecreatefromgif, imagecreatefrompng and imagecreatefromjpeg functions.
I would suggest that in the color function you replace this...
switch ( $file ) {
case 'gif' :
$img = imagecreatefromgif( $image );
break;
case 'png' :
$img = imagecreatefrompng( $image );
break;
case 'jpg' :
case 'jpeg' :
$img = imagecreatefromjpeg( $image );
break;
default:
return false;
}...with something like this...
if ( !in_array( $file, array( 'gif', 'jpg', 'jpeg', 'png' ) ) ) {
return false;
}
$response = wp_remote_request( $image, array( 'method' => 'GET' ) );
if ( is_wp_error( $response ) || empty( $response[ 'body' ] ) || $response['response']['code'] != 200 ) {
return false;
}
$img = imagecreatefromstring( wp_remote_retrieve_body( $response ) );I tested the above code on my shared hosted site where allow_url_fopen is disabled and it works as expected.
Metadata
Metadata
Assignees
Labels
No labels