summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornathanjo2013-09-09 03:47:31 (GMT)
committerg089h515r8062013-09-09 03:47:31 (GMT)
commitdc7788af994a78769a6e5534437185a27587827f (patch)
treee72fd91ed636b82e9df9eb8dedd91ff637e316ad
parent96403e81333ea631f7660ffd6f174d6ecde7de1f (diff)
Issue #[2076937] Support URI format as url type.
-rw-r--r--image_url_formatter.module11
1 files changed, 11 insertions, 0 deletions
diff --git a/image_url_formatter.module b/image_url_formatter.module
index d740222..a94b49e 100644
--- a/image_url_formatter.module
+++ b/image_url_formatter.module
@@ -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'];