doubleclick-for-wp icon indicating copy to clipboard operation
doubleclick-for-wp copied to clipboard

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

Open benlk opened this issue 6 years ago • 0 comments

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:

  • mappings is not sizeMapping
  • Because non-lazyload widgets are initialized off of jQuery('.dfw-unit:not(.dfw-lazy-load)').dfp( window.dfw ); directly, there's no sizeMapping key set to provide sizes there.

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:

  • [ ] Change the localization to output sizeMapping rather than 'mappings'
  • [ ] make sure that lazy-load and non-lazy-load use the same source of configuration options: #95 encompasses this

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

benlk avatar Feb 07 '19 19:02 benlk