/*
* Fake an attachment model - needs all fields used by template.
* Note that the default value must be a URL, NOT an attachment ID.
*/
$ext =
substr( $this->setting->default, -3
);
$type =
in_array( $ext, array
( 'jpg', 'png', 'gif', 'bmp', 'webp'
), true
) ? 'image' : 'document';
$default_attachment = array
( 'id' => 1,
'url' =>
$this->setting->default,
'type' =>
$type,
'icon' =>
wp_mime_type_icon( $type ),
'title' =>
wp_basename( $this->setting->default
),
);
if ( 'image' ===
$type ) { $default_attachment['sizes'
] = array
( 'full' => array
( 'url' =>
$this->setting->default
),
);
} $this->json
['defaultAttachment'
] =
$default_attachment;
}