Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
I
image_url_formatter
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
image_url_formatter
Commits
dc7788af
Commit
dc7788af
authored
Sep 09, 2013
by
nathanjo
Committed by
g089h515r806
Sep 09, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #[2076937] Support URI format as url type.
parent
96403e81
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
image_url_formatter.module
image_url_formatter.module
+11
-0
No files found.
image_url_formatter.module
View file @
dc7788af
...
...
@@ -8,6 +8,7 @@
/**
* Define constants for determine which type of URL should be used.
*/
define
(
'IMAGE_URL_FORMATTER_URI_PATH'
,
'3'
);
define
(
'IMAGE_URL_FORMATTER_RELATIVE_PATH'
,
'2'
);
define
(
'IMAGE_URL_FORMATTER_ABSOLUTE_PATH'
,
'1'
);
define
(
'IMAGE_URL_FORMATTER_FULL_URL'
,
'0'
);
...
...
@@ -54,12 +55,14 @@ function image_url_formatter_field_formatter_settings_form($field, $instance, $v
'#title'
=>
t
(
'URL type'
),
'#type'
=>
'radios'
,
'#options'
=>
array
(
IMAGE_URL_FORMATTER_URI_PATH
=>
t
(
'URI path'
),
IMAGE_URL_FORMATTER_RELATIVE_PATH
=>
t
(
'Relative file path'
),
IMAGE_URL_FORMATTER_ABSOLUTE_PATH
=>
t
(
'Absolute file path (recommended)'
),
IMAGE_URL_FORMATTER_FULL_URL
=>
t
(
'Full URL'
),
),
'#default_value'
=>
$settings
[
'url_type'
],
);
$element
[
'url_type'
][
IMAGE_URL_FORMATTER_URI_PATH
][
'#description'
]
=
t
(
"Uses the URI path, like: 'public://image.png'"
);
$element
[
'url_type'
][
IMAGE_URL_FORMATTER_RELATIVE_PATH
][
'#description'
]
=
t
(
"No base URL or leading slash, like: 'sites/default/files/image.png'"
);
$element
[
'url_type'
][
IMAGE_URL_FORMATTER_ABSOLUTE_PATH
][
'#description'
]
=
t
(
"With leading slash, no base URL, like: '/sites/default/files/image.png'"
);
$element
[
'url_type'
][
IMAGE_URL_FORMATTER_FULL_URL
][
'#description'
]
=
t
(
"Like: 'http://example.com/sites/default/files/image.png'"
);
...
...
@@ -98,6 +101,10 @@ function image_url_formatter_field_formatter_settings_summary($field, $instance,
$summary
=
array
();
switch
(
$settings
[
'url_type'
])
{
case
IMAGE_URL_FORMATTER_URI_PATH
:
$summary
[]
=
t
(
'Use uri path'
);
break
;
case
IMAGE_URL_FORMATTER_RELATIVE_PATH
:
$summary
[]
=
t
(
'Use relative path'
);
break
;
...
...
@@ -194,6 +201,10 @@ function theme_image_url_formatter($variables) {
if
(
drupal_strlen
(
$item
[
'title'
])
>
0
)
{
$image
[
'title'
]
=
$item
[
'title'
];
}
// Return the URI path.
if
(
$variables
[
'url_type'
]
==
3
)
{
return
$item
[
'uri'
];
}
$output
=
file_create_url
(
$item
[
'uri'
]);
if
(
$variables
[
'image_style'
])
{
$image
[
'style_name'
]
=
$variables
[
'image_style'
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment