AnswerBun.com

Changing library path with hook_library_info_alter

Drupal Answers Asked by Extect on September 8, 2020

I am having difficulties to change the library path defined by another module in *.libraries.yml via hook_library_info_alter

Essentially I have one module defining a library component in its *.libraries.yml like that:

# Font Awesome
fontawesome:
  version: 4.7.0
  css:
    component:
      /libraries/fontawesome/css/font-awesome.min.css: {minified: true }

How has my hook to look like to change to path to:

/libraries/fontawesome/web-fonts-with-css/font-awesome.min.css

Thanks for helping me!

One Answer

I pushed my patch for social icons module to add dynamic font awesome css here https://www.drupal.org/project/social_icons/issues/2984954

This is helpful to you.

if (isset($libraries['font-awesome'])) {
     $library_key = key($libraries['font-awesome']['css']['theme']);
     $library_array = $libraries['font-awesome']['css']['theme'][$library_key];
     unset($libraries['font-awesome']['css']['theme'][$library_key]);
     $libraries['font-awesome']['css']['theme'][$font_awesome_url] = $library_array;
}

Answered by Asif on September 8, 2020

Add your own answers!

Related Questions

Social Media Embed Problems With the URL Embed module

0  Asked on November 30, 2021 by mckinzie25

 

Contextual links for node blocks

3  Asked on November 28, 2021

   

Set node to flagged by default

1  Asked on November 28, 2021 by andrew-morris

     

How do I replace drush_set_error()?

1  Asked on November 28, 2021

   

Get file ID and path to use in View template

1  Asked on November 25, 2021 by srodrig

         

How to use drupal_add_library with a module?

2  Asked on November 25, 2021

   

Ajax Form Not Working in some Some Regions

2  Asked on November 23, 2021 by sandesh-yadav

     

Facebook Album fetcher

1  Asked on November 23, 2021 by rajat-goyal

 

Condition on current moderation state

2  Asked on November 23, 2021 by paul-cappucci

   

how to apply a css code for a specific screen size

1  Asked on November 23, 2021 by coding-mv

 

hook_entity_predelete never called

0  Asked on November 23, 2021

   

User reference and Views 3 and Panels 3

1  Asked on November 21, 2021

     

MetaTag with JSON API won’t serialize

2  Asked on November 21, 2021 by johnventions

   

How to disable Rich Text Editor in image field caption ?

1  Asked on November 19, 2021 by lee-woodman

   

search block form not accepting special characters in drupal 7

1  Asked on November 19, 2021 by blueztechz

   

Unknown engine type outputformat

1  Asked on November 19, 2021 by gilles9999

     

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir