Skip to content

Commit

Permalink
FEATURE: add support for fluid ad size in Google Ad Manager
Browse files Browse the repository at this point in the history
No width or height will be set on containers when ad size is fluid.
  • Loading branch information
nlalonde committed Jan 15, 2020
1 parent cf27a7b commit 116f9dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions assets/javascripts/discourse/components/google-dfp-ad.js.es6
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Expand Up @@ -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
Expand Down

0 comments on commit 116f9dd

Please sign in to comment.