Skip to content

Commit

Permalink
Make the inline ads scale by javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelmdLow committed Feb 13, 2024
1 parent 22ced1b commit dab8d93
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions ads/templates/ads/advertisement_inline.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
<div class="o-article-embed o-article-embed--advertisement">
<div class="o-article-embed__advertisement">
<div class="o-advertisement o-advertisement--banner o-advertisement--center">
<div class="adslot" id="{{ div_id }}" data-size="banner" data-dfp="{{ dfp }}">
<div class="o-advertisement o-advertisement--center">
<div class="adslot" id="{{ div_id }}" data-dfp="{{ dfp }}">
{% comment %}
See:
https://developers.google.com/publisher-tag/guides/get-started
{% endcomment %}
<script>
googletag.cmd.push(function() {
googletag.display('{{ div_id }}');
});
var size = "";
if(screen.width > 500) {
size = "banner";
} else if (screen.width > 320) {
size = "mobile-leaderboard";
}
if(screen.width > 320) {
var ad = document.getElementById("{{div_id}}");
ad.parentNode.classList.add("o-advertisement--" + size);
ad.setAttribute("data-size", size);
googletag.cmd.push(function() {
googletag.display('{{ div_id }}');
});
}
</script>
</div>
</div>

<div class="o-advertisement o-advertisement--mobile-leaderboard o-advertisement--center">
<div class="adslot" id="mobile-ad--{{ div_id }}" data-size="mobile-leaderboard" data-dfp="{{ dfp }}">
{% comment %}
See:
https://developers.google.com/publisher-tag/guides/get-started
{% endcomment %}
<script>
googletag.cmd.push(function() {
googletag.display('mobile-ad--{{ div_id }}');
});
</script>
</div>
</div>
</div>
</div>
</div>

0 comments on commit dab8d93

Please sign in to comment.