Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow uses of tokens in contact image title/alt #651

Open
wants to merge 1 commit into
base: 7.x-master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions modules/views/civicrm/civicrm_handler_field_contact_image.inc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class civicrm_handler_field_contact_image extends views_handler_field {

$form['title'] = array(
'#title' => t('Title attribute'),
'#description' => t('The text to use as value for the <code>img</code> tag <code>title</code> attribute.'),
'#description' => t('The text to use as value for the <code>img</code> tag <code>title</code> attribute. You may enter data from this view as per the "Replacement patterns" below.'),
'#type' => 'textfield',
'#default_value' => $this->options['title'],
'#dependency' => array(
Expand All @@ -52,7 +52,7 @@ class civicrm_handler_field_contact_image extends views_handler_field {

$form['alt'] = array(
'#title' => t('Alt attribute'),
'#description' => t('The text to use as value for the <code>img</code> tag <code>alt</code> attribute.'),
'#description' => t('The text to use as value for the <code>img</code> tag <code>alt</code> attribute. You may enter data from this view as per the "Replacement patterns" below.'),
'#type' => 'textfield',
'#default_value' => $this->options['alt'],
'#dependency' => array(
Expand Down Expand Up @@ -117,10 +117,13 @@ class civicrm_handler_field_contact_image extends views_handler_field {
if ($this->options['url_only']) {
return $value;
}
$tokens = $this->get_render_tokens([]);
$title = $this->render_altered(['text' => $this->options['title']], $tokens);
$alt = $this->render_altered(['text' => $this->options['alt']], $tokens);
$image = array(
'path' => $value,
'title' => $this->options['title'],
'alt' => $this->options['alt'],
'title' => $title,
'alt' => $alt,
);
$directory = $this->get_civi_relative_upload_path();
if (!empty($this->options['image_style']) && module_exists('image') && $directory !== FALSE) {
Expand Down