$49

Ad Wizard

Documentation  •  Changelog

Documentation

The `options` parameter

There are two different functions to quickly render an ad:

Both of these methods accept an "options" parameter. The options parameter is a configuration object, containing one or more of the following groups:

{
    'image': {},
    'attr': {},
    'js': {}
}

Default Options

{
    'image': {
        'transform': null,
        'retina': false
    },
    'attr': {
        'class': 'adWizard-ad',
        'style': 'cursor:pointer'
    },
    'js': {
        'click': 'adWizard.click({id}, \'{url}\')'
    }
}

All of these options can be overridden in Twig.


`image`

You can overwrite these defaults by following the instructions for image transforms...


`attr`

Any attributes that you want to apply to the `<img>` tag being generated.

{
    'attr': {
        'alt': '{myAltField}',
        'title': '{myAltTitle}'
    }
}

By default, these reference the attributes of your ad. You can use a dot-notation to drill deeper into related elements.

{
    'attr': {
        'alt': '{image.imageAltField}',
    }
}

`js`

Any event that would be prefixed by "on" is welcome here.

{
    'js': {
        'click': "alert('Ad clicked')",
        'mouseenter': "alert('Ad hovered')"
    }
}

These commands will be automatically prefixed with "on", and added to the attr options.

It's the exact same as if you were to do this:

{
    'attr': {
        'onclick': "alert('Ad clicked')",
        'onmouseenter': "alert('Ad hovered')"
    }
}