Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
While trying to fumble though getting the responsive tags to work on a new site, I ran across an issue on 8.x that I haven't seen on 7.x which is a new div with classes to encompass the google adsense code, however there are no classes appended...
Looking at adsense-ad.html.twig it "should" be working, but that's beyond my knowledge of why it isn't. It's also not spitting out "styles"?
adsense-ad.html.twig
{#
/**
* @file
* AdSense HTML wrapper.
*/
#}
<div class="{{ classes }}">
<div class="adsense" style="{{ style }}">
{{ content }}
</div>
</div>
Actual Output Example
<section id="block-adsense" class="block clearfix ...">
<div class="field field--name-body ...">
<div class="responsive"><!-- my custom div -->
<div class="">
<div class="adsense" style="">
...
Any ideas why the classes and style isn't being output? Using Bootstrap 3.5 as the theme.
Comments
Comment #2
pmaguniaNot sure this helps, but adding CSS styles inline is not good programming practice. 'Inline' CSS is found on the page instead of a stylesheet.
Its best to use classes and stylesheets.
Comment #3
philsward CreditAttribution: philsward commented@pmagunia Not sure if it helps with this situation.
The twig code I referenced comes from the module. Not sure why it's trying to add inline styles, that's a maintainer question.
Still begs the question why the classes aren't being output at all though? They're... just... empty.
Comment #4
jcnventura CreditAttribution: jcnventura at Wunder commentedThe reason why inline styles are used is because block dimensions are set accordingly to the ad dimension. And it is actually possible to have custom ad dimensions, which make it impossible to have a CSS class for all possible dimensions. Unless of course, I added 1 million classes to account for all possible variations of width and height between 1 and 1000px.
I've got no clue why classes and styles are not set in your case. Try to debug the template_preprocess_adsense_ad() function in adsense.module to check if those values are set correctly.
In any case, I'm changing the template slightly to not display empty class or style attributes.
Comment #6
jcnventura CreditAttribution: jcnventura at Wunder commented