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
dda9c28c
Commit
dda9c28c
authored
15 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#523520
by c960657: image_style_generate_url() and image_style_url() do the same.
parent
3cad9f41
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
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/image/image.module
+3
-30
3 additions, 30 deletions
modules/image/image.module
modules/image/image.test
+0
-15
0 additions, 15 deletions
modules/image/image.test
with
3 additions
and
45 deletions
modules/image/image.module
+
3
−
30
View file @
dda9c28c
...
@@ -297,7 +297,7 @@ function image_style_generate() {
...
@@ -297,7 +297,7 @@ function image_style_generate() {
$destination
=
image_style_path
(
$style
[
'name'
],
$path
);
$destination
=
image_style_path
(
$style
[
'name'
],
$path
);
// Check that it's a defined style and that access was granted by
// Check that it's a defined style and that access was granted by
// image_style_
generate_
url().
// image_style_url().
if
(
!
$style
||
!
cache_get
(
'access:'
.
$style_name
.
':'
.
$path_md5
,
'cache_image'
))
{
if
(
!
$style
||
!
cache_get
(
'access:'
.
$style_name
.
':'
.
$path_md5
,
'cache_image'
))
{
drupal_access_denied
();
drupal_access_denied
();
exit
();
exit
();
...
@@ -401,32 +401,6 @@ function image_style_flush($style) {
...
@@ -401,32 +401,6 @@ function image_style_flush($style) {
cache_clear_all
(
'*'
,
'cache_page'
,
TRUE
);
cache_clear_all
(
'*'
,
'cache_page'
,
TRUE
);
}
}
/**
* Return the complete URL to an image when using a style.
*
* If the image has already been created then its location will be returned. If
* it does not then image_style_generate_url() will be called.
*
* @param $style_name
* The name of the style to be used with this image.
* @param $path
* The path to the image.
* @return
* The absolute URL where a style image can be downloaded, suitable for use
* in an <img> tag. If the site is using the default method for generating
* images, the image may not yet exist and will only be created when a
* visitor's browser requests the file.
* @see image_style_generate_url()
* @see image_style_path()
*/
function
image_style_url
(
$style_name
,
$path
)
{
$style_path
=
image_style_path
(
$style_name
,
$path
);
if
(
file_exists
(
$style_path
))
{
return
file_create_url
(
$style_path
);
}
return
image_style_generate_url
(
$style_name
,
$path
);
}
/**
/**
* Return the URL for an image derivative given a style and image path.
* Return the URL for an image derivative given a style and image path.
*
*
...
@@ -444,14 +418,13 @@ function image_style_url($style_name, $path) {
...
@@ -444,14 +418,13 @@ function image_style_url($style_name, $path) {
* The absolute URL where a style image can be downloaded, suitable for use
* The absolute URL where a style image can be downloaded, suitable for use
* in an <img> tag. Requesting the URL will cause the image to be created.
* in an <img> tag. Requesting the URL will cause the image to be created.
* @see image_style_generate()
* @see image_style_generate()
* @see image_style_url()
*/
*/
function
image_style_
generate_
url
(
$style_name
,
$path
)
{
function
image_style_url
(
$style_name
,
$path
)
{
$destination
=
image_style_path
(
$style_name
,
$path
);
$destination
=
image_style_path
(
$style_name
,
$path
);
// If the image already exists use that rather than regenerating it.
// If the image already exists use that rather than regenerating it.
if
(
file_exists
(
$destination
))
{
if
(
file_exists
(
$destination
))
{
return
image_style_url
(
$style_name
,
$path
);
return
file_create_url
(
$destination
);
}
}
// Disable page cache for this request. This prevents anonymous users from
// Disable page cache for this request. This prevents anonymous users from
...
...
This diff is collapsed.
Click to expand it.
modules/image/image.test
+
0
−
15
View file @
dda9c28c
...
@@ -86,21 +86,6 @@ class ImageStylesPathAndUrlUnitTest extends DrupalWebTestCase {
...
@@ -86,21 +86,6 @@ class ImageStylesPathAndUrlUnitTest extends DrupalWebTestCase {
$expected
=
file_create_url
(
image_style_path
(
$this
->
style_name
,
$this
->
image_with_generated
));
$expected
=
file_create_url
(
image_style_path
(
$this
->
style_name
,
$this
->
image_with_generated
));
$this
->
assertEqual
(
$actual
,
$expected
,
t
(
'Got the download URL for an existing file.'
));
$this
->
assertEqual
(
$actual
,
$expected
,
t
(
'Got the download URL for an existing file.'
));
}
}
/**
* Test image_style_generate_url().
*/
function
testImageStyleGenerateUrl
()
{
// Test it with no generated file.
$actual
=
image_style_generate_url
(
$this
->
style_name
,
$this
->
image_without_generated
);
$expected
=
url
(
'image/generate/'
.
$this
->
style_name
.
'/'
.
$this
->
image_without_generated
,
array
(
'absolute'
=>
TRUE
));
$this
->
assertEqual
(
$actual
,
$expected
,
t
(
'Got the generate URL for a non-existent file.'
));
// Now test it with a generated file.
$actual
=
image_style_generate_url
(
$this
->
style_name
,
$this
->
image_with_generated
);
$expected
=
file_create_url
(
image_style_path
(
$this
->
style_name
,
$this
->
image_with_generated
));
$this
->
assertEqual
(
$actual
,
$expected
,
t
(
'Got the download URL for an existing file.'
));
}
}
}
/**
/**
...
...
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