ajaxyfied image links, fix #3
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Template\Attribute;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Render\Element;
|
||||
|
||||
// function edlptheme_preprocess_input(&$vars){
|
||||
// dsm($vars, 'vars');
|
||||
@@ -133,3 +135,28 @@ function edlptheme_preprocess_node__enregistrement__player_cartel(&$vars){
|
||||
$vars['col_right'] = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepares variables for image formatter templates.
|
||||
*
|
||||
* Default template: image-formatter.html.twig.
|
||||
*
|
||||
* @param array $variables
|
||||
* An associative array containing:
|
||||
* - item: An ImageItem object.
|
||||
* - item_attributes: An optional associative array of html attributes to be
|
||||
* placed in the img tag.
|
||||
* - image_style: An optional image style.
|
||||
* - url: An optional \Drupal\Core\Url object.
|
||||
*/
|
||||
function edlptheme_preprocess_image_formatter(&$vars){
|
||||
if(isset($vars['url'])){
|
||||
$system_path = $vars['url']->getInternalPath();
|
||||
$vars['link_attributes'] = new Attribute(array(
|
||||
'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
|
||||
'class' => array('ajax-link')
|
||||
));
|
||||
// dpm($vars);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
{#
|
||||
/**
|
||||
* @file
|
||||
* Theme override to display a formatted image field.
|
||||
*
|
||||
* Available variables:
|
||||
* - image: A collection of image data.
|
||||
* - image_style: An optional image style.
|
||||
* - path: An optional array containing the link 'path' and link 'options'.
|
||||
* - url: An optional URL the image can be linked to.
|
||||
*
|
||||
* @see template_preprocess_image_formatter()
|
||||
*/
|
||||
#}
|
||||
{% if url %}
|
||||
<a href="{{ url }}" {{ link_attributes }}>{{ image }}</a>
|
||||
{% else %}
|
||||
{{ image }}
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user