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

8.0.x
Alex Pott 2015-07-27 14:39:40 +01:00
parent 42ff057e0a
commit 444c476a4b
6 changed files with 21 additions and 46 deletions

View File

@ -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.
*

View File

@ -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.
*/

View File

@ -91,7 +91,6 @@ class AddFeedTest extends WebTestBase {
'#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.');
}
}

View File

@ -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>

View File

@ -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;

View File

@ -1,16 +0,0 @@
{#
/**
* @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>