function dfp_format_size in Doubleclick for Publishers (DFP) 7.2
Same name and namespace in other branches
- 7 dfp.module \dfp_format_size()
Format the the size of an ad tag.
Parameters
array $variables: 'size' => A string in the format 123x321,987x789.
Return value
string A string in the format [456, 654] or [[123, 321], [987, 789]].
4 calls to dfp_format_size()
- dfpDisplayTagTest::testDisplayTag in tests/
dfp.test - DFPUnitTest::testDFPformatSize in tests/
dfp.test - template_preprocess_dfp_tag in ./
dfp.module - Preprocess function for DFP tags.
- _dfp_js_slot_definition in ./
dfp.module - Helper function to build the javascript needed to define an ad slot and add it to the head tag.
File
- ./
dfp.module, line 626
Code
function dfp_format_size($size) {
$formatted_sizes = array();
$sizes = explode(',', check_plain($size));
foreach ($sizes as $size) {
$formatted_size = explode('x', trim($size));
array_walk($formatted_size, function (&$arg) {
$arg = (int) $arg;
});
$formatted_sizes[] = $formatted_size;
}
return count($formatted_sizes) == 1 ? $formatted_sizes[0] : $formatted_sizes;
}