Commit dc7788af authored by nathanjo's avatar nathanjo Committed by g089h515r806

Issue #[2076937] Support URI format as url type.

parent 96403e81
......@@ -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'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment