INN / doubleclick-for-wp

WordPress plugin for serving Google Ad Manager ads
https://wordpress.org/plugins/doubleclick-for-wp/
GNU General Public License v2.0
25 stars 11 forks source link

non-lazyload ads are being loaded with incomplete options settings, and the mapping object's ad_sizes array is misformatted #96

Open benlk opened 5 years ago

benlk commented 5 years ago

In the sizeMapping array in window.dfw, each individual mapping takes the form of an object/associative array with the keys browser and ad_sizes. Here's what jquery.dfp.js' docs say the plugin expects:

$('selector').dfp({
    dfpID:'xxxxxxxxx',
    sizeMapping: {
        'my-default': [
            {browser: [1024, 768], ad_sizes: [980, 185]},
            {browser: [ 980, 600], ad_sizes: [[728, 90], [640, 480]]},
            {browser: [   0,   0], ad_sizes: [88, 31]}
        ],
    }
});

Here's what this plugin is outputting upon the page, cleaned up to match the formatting:

window.dfw = {
  "mappings": {
    "mapping1": [
      { "browser": [ 1220, 1 ], "ad_sizes": [ [728,90] ] }
    ]
  }
}

Two things are wrong here:

Lazyload widgets are initialized off of window.dfp_options, which is modified from window.dfw:

https://github.com/INN/doubleclick-for-wp/blob/f73e00d5cf8897fd75706453986b21a0e6e4a8a2/js/jquery.dfw.js#L35-L39

There are several aspects to the fix for this:

As a temporary fix, sites affected can check the box to enable lazy-load for all widgets.