function dfp_format_size in Doubleclick for Publishers (DFP) 7
Same name and namespace in other branches
- 7.2 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_display_tag.test - DFPUnitTest::testDFPformatSize in tests/
dfp_unit.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 592
Code
function dfp_format_size($size) {
$formatted_sizes = array();
$sizes = explode(',', check_plain($size));
foreach ($sizes as $size) {
$formatted_size = explode('x', trim($size));
$formatted_sizes[] = '[' . implode(', ', $formatted_size) . ']';
}
return count($formatted_sizes) == 1 ? $formatted_sizes[0] : '[' . implode(', ', $formatted_sizes) . ']';
}