Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
37607d88
Commit
37607d88
authored
14 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#696150
by mfb, pwolanin: image_gd_save() does not support remote stream wrappers.
parent
05ff4512
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/system/image.gd.inc
+19
-8
19 additions, 8 deletions
modules/system/image.gd.inc
with
19 additions
and
8 deletions
modules/system/image.gd.inc
+
19
−
8
View file @
37607d88
...
...
@@ -244,18 +244,24 @@ function image_gd_load(stdClass $image) {
* @param $image
* An image object.
* @param $destination
* A string file path where the image should be saved.
* @param $extension
* A string containing one of the following extensions: gif, jpg, jpeg, png.
* A string file URI or path where the image should be saved.
* @return
* TRUE or FALSE, based on success.
*
* @see image_save()
*/
function
image_gd_save
(
stdClass
$image
,
$destination
)
{
// Convert URI to a normal path because PHP apparently has some gaps in stream wrapper support.
if
(
$wrapper
=
file_stream_wrapper_get_instance_by_uri
(
$destination
))
{
$destination
=
$wrapper
->
realpath
();
$scheme
=
file_uri_scheme
(
$destination
);
// Work around lack of stream wrapper support in imagejpeg() and imagepng().
if
(
$scheme
&&
file_stream_wrapper_valid_scheme
(
$scheme
))
{
// If destination is not local, save image to temporary local file.
$local_wrappers
=
file_get_stream_wrappers
(
STREAM_WRAPPERS_LOCAL
);
if
(
!
isset
(
$local_wrappers
[
$scheme
]))
{
$permanent_destination
=
$destination
;
$destination
=
drupal_tempnam
(
'temporary://'
,
'gd_'
);
}
// Convert stream wrapper URI to normal path.
$destination
=
drupal_realpath
(
$destination
);
}
$extension
=
str_replace
(
'jpg'
,
'jpeg'
,
$image
->
info
[
'extension'
]);
...
...
@@ -264,7 +270,7 @@ function image_gd_save(stdClass $image, $destination) {
return
FALSE
;
}
if
(
$extension
==
'jpeg'
)
{
return
$function
(
$image
->
resource
,
$destination
,
variable_get
(
'image_jpeg_quality'
,
75
));
$success
=
$function
(
$image
->
resource
,
$destination
,
variable_get
(
'image_jpeg_quality'
,
75
));
}
else
{
// Always save PNG images with full transparency.
...
...
@@ -272,8 +278,13 @@ function image_gd_save(stdClass $image, $destination) {
imagealphablending
(
$image
->
resource
,
FALSE
);
imagesavealpha
(
$image
->
resource
,
TRUE
);
}
return
$function
(
$image
->
resource
,
$destination
);
$success
=
$function
(
$image
->
resource
,
$destination
);
}
// Move temporary local file to remote destination.
if
(
isset
(
$permanent_destination
)
&&
$success
)
{
return
(
bool
)
file_unmanaged_move
(
$destination
,
$permanent_destination
,
FILE_EXISTS_REPLACE
);
}
return
$success
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment