Override pager text elements with image

Created on 21 March 2018, almost 7 years ago
Updated 12 January 2025, about 1 month ago

Currently there is no easy way to replace the following pager tags with images/icons.
We are only allowed to do things like that

$variables['tags']['first'] = t('my_first');
  $variables['tags']['previous'] = t('my_previous');
  $variables['tags']['next'] = t('my_next');
  $variables['tags']['last'] = t('my_last');

and not

$variables['tags']['first'] = '<img  alt="first page" src="/..." />';
  $variables['tags']['previous'] = '<img  alt="previous page" src="/..." />';
  $variables['tags']['next'] = '<img  alt="next_page" src="/..." />';
  $variables['tags']['last'] = '<img  alt="last page" src="/..." />';

this because, the function theme_pager_link($variables) includes the check_plain($text)
return '<a' . drupal_attributes($attributes) . '>' . check_plain($text) . '</a>';
It would be great to add a test to know if an image is used and not only a text. Something like this:

function theme_pager_previous($variables) {
  isset($variables['img'] ) ? $img = $variables['img']; 
  $text = $variables['text'];
  $element = $variables['element'];
  $interval = $variables['interval'];
  $parameters = $variables['parameters'];
  
  ... // add $img if isset within $output 
$output = theme('pager_link', array( 'img' => $img, 'text' => $text, 'page_new' => $page_new, 'element' => $element, 'parameters' => $parameters));
  .... and inside function theme_pager_link($variables)
 if ( isset($img) ){
return '<a' . drupal_attributes($attributes) . '>' . $img . '</a>';
}else{
return '<a' . drupal_attributes($attributes) . '>' . check_plain($text) . '</a>';
}
Feature request
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇫🇷France Pierre__

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024