From 116f9dd238465219ca06c2cd45e2b8996ca28905 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 15 Jan 2020 16:52:02 -0500 Subject: [PATCH] FEATURE: add support for fluid ad size in Google Ad Manager No width or height will be set on containers when ad size is fluid. --- .../discourse/components/google-dfp-ad.js.es6 | 12 ++++++++++-- config/settings.yml | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 index cd94b661..a1234b9f 100755 --- a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 +++ b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 @@ -126,6 +126,10 @@ function getWidthAndHeight(placement, settings, isMobile) { renderCounts[placement] += 1; } + if (size === "fluid") { + return { width: 'fluid', height: 'fluid' }; + } + const sizeObj = { width: parseInt(splitWidthInt(size), 10), height: parseInt(splitHeightInt(size), 10) @@ -281,12 +285,16 @@ export default AdComponent.extend({ @computed("width", "height") adWrapperStyle(w, h) { - return `width: ${w}px; height: ${h}px;`.htmlSafe(); + if (w !== 'fluid') { + return `width: ${w}px; height: ${h}px;`.htmlSafe(); + } }, @computed("width") adTitleStyleMobile(w) { - return `width: ${w}px;`.htmlSafe(); + if (w !== 'fluid') { + return `width: ${w}px;`.htmlSafe(); + } }, @computed( diff --git a/config/settings.yml b/config/settings.yml index 68dd43ee..871c7295 100755 --- a/config/settings.yml +++ b/config/settings.yml @@ -163,6 +163,7 @@ dfp_plugin: default: "728*90 - leaderboard" type: list choices: &dfp_choices + - fluid - 728*90 - leaderboard - 336*280 - large rectangle - 300*250 - medium rectangle