Commit 444c476a authored by alexpott's avatar alexpott

Issue #2426967 by mortendk, BarisW, joelpittet, akalata, jwilson3,...

Issue #2426967 by mortendk, BarisW, joelpittet, akalata, jwilson3, Manjit.Singh, joginderpc, rteijeiro, mgifford, LewisNyman, Manuel Garcia, markconroy: Feed icon should be a CSS background image not a image file
parent 42ff057e
......@@ -1066,30 +1066,6 @@ function template_preprocess_item_list(&$variables) {
}
}
/**
* Prepares variables for feed icon templates.
*
* Default template: feed-icon.html.twig.
*
* @param array $variables
* An associative array containing:
* - url: An internal system path or a fully qualified external URL of the
* feed.
* - title: A descriptive title of the feed.
*/
function template_preprocess_feed_icon(&$variables) {
$text = t('Subscribe to !feed-title', array('!feed-title' => $variables['title']));
$variables['icon'] = array(
'#theme' => 'image__feed_icon',
'#uri' => 'core/misc/feed.png',
'#width' => 16,
'#height' => 16,
'#alt' => $text,
);
// Stripping tags because that's what l() used to do.
$variables['attributes']['title'] = strip_tags($text);
}
/**
* Returns HTML for an indentation div; used for drag and drop tables.
*
......
......@@ -164,6 +164,19 @@ abbr.ajax-changed {
padding: 1px 20px 1px 0;
}
/**
* Feed Icon.
* Markup generated by feed-icon.html.twig.
*/
.feed-icon {
background: url(../../../misc/feed.png) no-repeat;
overflow: hidden;
text-indent: -9999px;
display: block;
width: 16px;
height: 16px;
}
/**
* Markup generated by pager.html.twig.
*/
......
......@@ -91,7 +91,6 @@ function testFeedIconEscaping() {
'#title' => '<>&"\'',
);
$text = \Drupal::service('renderer')->renderRoot($variables);
preg_match('/title="(.*?)"/', $text, $matches);
$this->assertEqual($matches[1], 'Subscribe to &amp;&quot;&#039;', 'feed_icon template escapes reserved HTML characters.');
$this->assertEqual(trim(strip_tags($text)), 'Subscribe to &lt;&gt;&amp;&quot;&#039;', 'feed_icon template escapes reserved HTML characters.');
}
}
......@@ -5,14 +5,13 @@
*
* Available variables:
* - url: An internal system path or a fully qualified external URL of the feed.
* - icon: The rendered HTML (<img> tag) for the feed icon image.
* - attributes: Remaining HTML attributes for the feed link.
* - title: A descriptive title of the feed link.
* - class: HTML classes to be applied to the feed link.
*
* @see template_preprocess_feed_icon()
*
* @ingroup themeable
*/
#}
<a href="{{ url }}"{{ attributes.addClass('feed-icon')|without('href') }}>{{ icon }}</a>
<a href="{{ url }}"{{ attributes.addClass('feed-icon') }}>
{{ 'Subscribe to @title'|t({'@title': title}) }}
</a>
......@@ -124,6 +124,10 @@ blockquote:after {
blockquote > p:first-child {
display: inline;
}
.feed-icon {
display: block;
margin: 25px 0 0 0;
}
img {
max-width: 100%;
height: auto;
......
{#
/**
* @file
* Theme override for a feed icon.
*
* Available variables:
* - url: An internal system path or a fully qualified external URL of the feed.
* - icon: The rendered HTML (<img> tag) for the feed icon image.
* - attributes: Remaining HTML attributes for the feed link.
* - title: A descriptive title of the feed link.
* - class: HTML classes to be applied to the feed link.
*
* @see template_preprocess_feed_icon()
*/
#}
<a href="{{ url }}"{{ attributes.addClass('feed-icon')|without('href') }}>{{ icon }}</a>
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