Link an image and add assets

Solutions

After a few hours I found out the solution for the issue of css and js assets. If I want to include the librairie from the Plugin controller to the template I had to use back_module/back instead of back/back who seems to be for global libraries from the theme. Still looking how to include an image.

Tags: Drupal / Drupal 8

Similar questions

Loading of assets via Libraries API
I'm writing a new module which has a dependency on an external library. In Drupal 7 I would use hook_libraries_info giving the name of the library the required assets and Drupal would search the valid locations, libraries directories, to load these assets when required. Drupal 8 introduces *.libraries.yml and after reading https://www.drupal.org/no...
Get path to theme assets in Twig template
I have a question about getting a path to an image in a Twig template. The image is not assigned to a field or something. Just a static image which is stored in "MYTHEME/image/icon/my-icon.png". In Drupal 7 I get the path in my node.template with the following code: How does it work with in Drupal 8? I tried to pass a variable in template_preproces...
How do I include JavaScript with assets (libraries.yml)?
This is my mytheme.libraries.yml file: This is my js/effect.js file: I created jquery.js in core folder of my site root. Even if I remove the dependency line from my libraries.yml and remove jquery syntax from my effect.js, I receive nothing on my site.
How to modify .htaccess to serve brotli compressed static assets over gziped ones?
I'm trying to use brotli compressed static assets with Advanced CSS/JS Aggregation as detailed here, https://www.drupal.org/node/2773807. The assets are created as they should be, but they're never served because the .htaccess file doesn't know to do that. lyncd.com has a short walkthrough, https://lyncd.com/2015/11/brotli-support-apache/, but I ha...
Random page rendering error: A stray renderRoot() invocation is causing bubbling of attached assets to break
I have a D8 site that's in development and I am getting this error thrown at random on pages which most of the time render quite happily. There doesn't seem to be any real pattern in it. I can see that it looks like it's designed to prevent the renderer creating an infinite loop (the code is on line 133 of core/lib/Drupal/Core/Render/Renderer.php),...
Attaching assets if the page contains a table
I want to attach a CSS file to a page only if it contains a table. I tried from the guide "Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 module" but it does not work. The hook itself and the condition works. The question is where I have to save the #attached array in the $types variable? I appreciate your help and feedback. PS: The fol...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.