metatag_favicons.metatag.inc 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <?php
  2. /**
  3. * @file
  4. * Metatag integration for the Metatag:favicons module.
  5. */
  6. /**
  7. * Implements hook_metatag_bundled_config_alter().
  8. */
  9. function metatag_favicons_metatag_bundled_config_alter(&$config) {
  10. $favicon = metatag_favicons_get_theme_favicon();
  11. if (!empty($favicon)) {
  12. $config['global']->config['shortcut icon'] = array('value' => $favicon);
  13. }
  14. }
  15. /**
  16. * Implements hook_metatag_info().
  17. */
  18. function metatag_favicons_metatag_info() {
  19. $info['groups']['favicons'] = array(
  20. 'label' => t('Favicons & touch icons'),
  21. 'description' => t('Meta tags for displaying favicons of various sizes and types. All values should be either absolute or relative URLs. No effects are added to the "precomposed" icons.'),
  22. 'form' => array(
  23. '#weight' => 100,
  24. ),
  25. );
  26. // favicons meta tags stack after the simple tags.
  27. $weight = 100;
  28. // Default values for each meta tag.
  29. $favicon_defaults = array(
  30. 'description' => '',
  31. 'class' => 'DrupalLinkMetaTag',
  32. 'group' => 'favicons',
  33. 'url' => TRUE,
  34. 'context' => array('global'),
  35. );
  36. $info['tags']['shortcut icon'] = array(
  37. 'label' => t('Default shortcut icon'),
  38. 'description' => t('The traditional favicon, must be either a GIF, ICO, JPG/JPEG or PNG image.'),
  39. 'weight' => ++$weight,
  40. 'element' => array(
  41. '#rel' => 'shortcut icon',
  42. '#theme' => 'metatag_shortcut_icon',
  43. ),
  44. ) + $favicon_defaults;
  45. $info['tags']['mask-icon'] = array(
  46. 'label' => t('Icon: SVG'),
  47. 'description' => t('A grayscale scalable vector graphic (SVG) file.'),
  48. 'weight' => ++$weight,
  49. 'element' => array(
  50. '#theme' => 'metatag_mask_icon',
  51. ),
  52. 'class' => 'DrupalMaskIconMetaTag',
  53. 'replaces' => array('icon_any'),
  54. ) + $favicon_defaults;
  55. $info['tags']['icon_16x16'] = array(
  56. 'label' => t('Icon: 16px x 16px'),
  57. 'description' => t('A PNG image that is 16px wide by 16px high.'),
  58. 'weight' => ++$weight,
  59. 'element' => array(
  60. '#rel' => 'icon',
  61. '#sizes' => '16x16',
  62. '#theme' => 'metatag_favicon',
  63. ),
  64. ) + $favicon_defaults;
  65. $info['tags']['icon_32x32'] = array(
  66. 'label' => t('Icon: 32px x 32px'),
  67. 'description' => t('A PNG image that is 32px wide by 32px high.'),
  68. 'weight' => ++$weight,
  69. 'element' => array(
  70. '#rel' => 'icon',
  71. '#sizes' => '32x32',
  72. '#theme' => 'metatag_favicon',
  73. ),
  74. ) + $favicon_defaults;
  75. $info['tags']['icon_96x96'] = array(
  76. 'label' => t('Icon: 96px x 96px'),
  77. 'description' => t('A PNG image that is 96px wide by 96px high.'),
  78. 'weight' => ++$weight,
  79. 'element' => array(
  80. '#rel' => 'icon',
  81. '#sizes' => '96x96',
  82. '#theme' => 'metatag_favicon',
  83. ),
  84. ) + $favicon_defaults;
  85. $info['tags']['icon_192x192'] = array(
  86. 'label' => t('Icon: 192px x 192px'),
  87. 'description' => t('A PNG image that is 192px wide by 192px high.'),
  88. 'weight' => ++$weight,
  89. 'element' => array(
  90. '#rel' => 'icon',
  91. '#sizes' => '192x192',
  92. '#theme' => 'metatag_favicon',
  93. ),
  94. ) + $favicon_defaults;
  95. $info['tags']['apple-touch-icon'] = array(
  96. 'label' => t('Apple touch icon: 60px x 60px'),
  97. 'description' => t('A PNG image that is 60px wide by 60px high. Used with the non-Retina iPhone, iPod Touch, and Android 2.1+ devices.'),
  98. 'weight' => ++$weight,
  99. 'element' => array(
  100. '#rel' => 'apple-touch-icon',
  101. '#theme' => 'metatag_favicon',
  102. ),
  103. ) + $favicon_defaults;
  104. $info['tags']['apple-touch-icon_72x72'] = array(
  105. 'label' => t('Apple touch icon: 72px x 72px'),
  106. 'description' => t('A PNG image that is 72px wide by 72px high. Used with the iPad mini and the first- and second-generation iPad (@1x display) on iOS <= 6.'),
  107. 'weight' => ++$weight,
  108. 'element' => array(
  109. '#rel' => 'apple-touch-icon',
  110. '#sizes' => '72x72',
  111. '#theme' => 'metatag_favicon',
  112. ),
  113. ) + $favicon_defaults;
  114. $info['tags']['apple-touch-icon_76x76'] = array(
  115. 'label' => t('Apple touch icon: 76px x 76px'),
  116. 'description' => t('A PNG image that is 76px wide by 76px high. Used with the iPad mini and the second-generation iPad (@1x display) on iOS >= 7.'),
  117. 'weight' => ++$weight,
  118. 'element' => array(
  119. '#rel' => 'apple-touch-icon',
  120. '#sizes' => '76x76',
  121. '#theme' => 'metatag_favicon',
  122. ),
  123. ) + $favicon_defaults;
  124. $info['tags']['apple-touch-icon_114x114'] = array(
  125. 'label' => t('Apple touch icon: 114px x 114px'),
  126. 'description' => t('A PNG image that is 114px wide by 114px high. Used with iPhone with @2x display running iOS <= 6.'),
  127. 'weight' => ++$weight,
  128. 'element' => array(
  129. '#rel' => 'apple-touch-icon',
  130. '#sizes' => '114x114',
  131. '#theme' => 'metatag_favicon',
  132. ),
  133. ) + $favicon_defaults;
  134. $info['tags']['apple-touch-icon_120x120'] = array(
  135. 'label' => t('Apple touch icon: 120px x 120px'),
  136. 'description' => t('A PNG image that is 120px wide by 120px high. Used with iPhone with @2x display running iOS >= 7.'),
  137. 'weight' => ++$weight,
  138. 'element' => array(
  139. '#rel' => 'apple-touch-icon',
  140. '#sizes' => '120x120',
  141. '#theme' => 'metatag_favicon',
  142. ),
  143. ) + $favicon_defaults;
  144. $info['tags']['apple-touch-icon_144x144'] = array(
  145. 'label' => t('Apple touch icon: 144px x 144px'),
  146. 'description' => t('A PNG image that is 144px wide by 144px high. Used with iPad with @2x display running iOS <= 6.'),
  147. 'weight' => ++$weight,
  148. 'element' => array(
  149. '#rel' => 'apple-touch-icon',
  150. '#sizes' => '144x144',
  151. '#theme' => 'metatag_favicon',
  152. ),
  153. ) + $favicon_defaults;
  154. $info['tags']['apple-touch-icon_152x152'] = array(
  155. 'label' => t('Apple touch icon: 152px x 152px'),
  156. 'description' => t('A PNG image that is 152px wide by 152px high. Used with iPad with @2x display running iOS >= 7.'),
  157. 'weight' => ++$weight,
  158. 'element' => array(
  159. '#rel' => 'apple-touch-icon',
  160. '#sizes' => '152x152',
  161. '#theme' => 'metatag_favicon',
  162. ),
  163. ) + $favicon_defaults;
  164. $info['tags']['apple-touch-icon_180x180'] = array(
  165. 'label' => t('Apple touch icon: 180px x 180px'),
  166. 'description' => t('A PNG image that is 180px wide by 180px high. Used with iPhone 6 Plus with @3x display.'),
  167. 'weight' => ++$weight,
  168. 'element' => array(
  169. '#rel' => 'apple-touch-icon',
  170. '#sizes' => '180x180',
  171. '#theme' => 'metatag_favicon',
  172. ),
  173. ) + $favicon_defaults;
  174. $info['tags']['apple-touch-icon-precomposed'] = array(
  175. 'label' => t('Apple touch icon (precomposed): 57px x 57px'),
  176. 'description' => t('A PNG image that is 57px wide by 57px high. Used with the non-Retina iPhone, iPod Touch, and Android 2.1+ devices.'),
  177. 'weight' => ++$weight,
  178. 'element' => array(
  179. '#rel' => 'apple-touch-icon-precomposed',
  180. '#theme' => 'metatag_favicon',
  181. ),
  182. ) + $favicon_defaults;
  183. $info['tags']['apple-touch-icon-precomposed_72x72'] = array(
  184. 'label' => t('Apple touch icon (precomposed): 72px x 72px'),
  185. 'description' => t('A PNG image that is 72px wide by 72px high. Used with the iPad mini and the first- and second-generation iPad (@1x display) on iOS <= 6.'),
  186. 'weight' => ++$weight,
  187. 'element' => array(
  188. '#rel' => 'apple-touch-icon-precomposed',
  189. '#sizes' => '72x72',
  190. '#theme' => 'metatag_favicon',
  191. ),
  192. ) + $favicon_defaults;
  193. $info['tags']['apple-touch-icon-precomposed_76x76'] = array(
  194. 'label' => t('Apple touch icon (precomposed): 76px x 76px'),
  195. 'description' => t('A PNG image that is 76px wide by 76px high. Used with the iPad mini and the second-generation iPad (@1x display) on iOS >= 7.'),
  196. 'weight' => ++$weight,
  197. 'element' => array(
  198. '#rel' => 'apple-touch-icon-precomposed',
  199. '#sizes' => '76x76',
  200. '#theme' => 'metatag_favicon',
  201. ),
  202. ) + $favicon_defaults;
  203. $info['tags']['apple-touch-icon-precomposed_114x114'] = array(
  204. 'label' => t('Apple touch icon (precomposed): 114px x 114px'),
  205. 'description' => t('A PNG image that is 114px wide by 114px high. Used with iPhone with @2x display running iOS <= 6.'),
  206. 'weight' => ++$weight,
  207. 'element' => array(
  208. '#rel' => 'apple-touch-icon-precomposed',
  209. '#sizes' => '114x114',
  210. '#theme' => 'metatag_favicon',
  211. ),
  212. ) + $favicon_defaults;
  213. $info['tags']['apple-touch-icon-precomposed_120x120'] = array(
  214. 'label' => t('Apple touch icon (precomposed): 120px x 120px'),
  215. 'description' => t('A PNG image that is 120px wide by 120px high. Used with iPhone with @2x display running iOS >= 7.'),
  216. 'weight' => ++$weight,
  217. 'element' => array(
  218. '#rel' => 'apple-touch-icon-precomposed',
  219. '#sizes' => '120x120',
  220. '#theme' => 'metatag_favicon',
  221. ),
  222. ) + $favicon_defaults;
  223. $info['tags']['apple-touch-icon-precomposed_144x144'] = array(
  224. 'label' => t('Apple touch icon (precomposed): 144px x 144px'),
  225. 'description' => t('A PNG image that is 144px wide by 144px high. Used with iPad with @2x display running iOS <= 6.'),
  226. 'weight' => ++$weight,
  227. 'element' => array(
  228. '#rel' => 'apple-touch-icon-precomposed',
  229. '#sizes' => '144x144',
  230. '#theme' => 'metatag_favicon',
  231. ),
  232. ) + $favicon_defaults;
  233. $info['tags']['apple-touch-icon-precomposed_152x152'] = array(
  234. 'label' => t('Apple touch icon (precomposed): 152px x 152px'),
  235. 'description' => t('A PNG image that is 152px wide by 152px high. Used with iPad with @2x display running iOS >= 7.'),
  236. 'weight' => ++$weight,
  237. 'element' => array(
  238. '#rel' => 'apple-touch-icon-precomposed',
  239. '#sizes' => '152x152',
  240. '#theme' => 'metatag_favicon',
  241. ),
  242. ) + $favicon_defaults;
  243. $info['tags']['apple-touch-icon-precomposed_180x180'] = array(
  244. 'label' => t('Apple touch icon (precomposed): 180px x 180px'),
  245. 'description' => t('A PNG image that is 180px wide by 180px high. Used with iPhone 6 Plus with @3x display.'),
  246. 'weight' => ++$weight,
  247. 'element' => array(
  248. '#rel' => 'apple-touch-icon-precomposed',
  249. '#sizes' => '180x180',
  250. '#theme' => 'metatag_favicon',
  251. ),
  252. ) + $favicon_defaults;
  253. return $info;
  254. }