function ubik_photo_meta_microdata_id($id = '')
{
    // If no ID was passed (and it probably wasn't) try and fetch the correct ID
    if (empty($id)) {
        $id = ubik_photo_meta_attachment_id();
    }
    // An opportunity to abort
    if (empty($id) || apply_filters('ubik_photo_meta_microdata_switch', true) === false) {
        return;
    }
    // This is used twice so let's make it easy
    $attachment_id = esc_attr(apply_filters('ubik_photo_meta_microdata_id', 'attachment-' . $id));
    // Return the HTML output fragment
    return ' id="' . $attachment_id . '" itemscope itemref="' . $attachment_id . '" itemtype="http://schema.org/ImageObject"';
}
function ubik_photo_meta()
{
    // Get the attachment ID
    $id = ubik_photo_meta_attachment_id();
    // Exit early if necessary
    if (empty($id)) {
        return;
    }
    // Filter what fields to display (and in what order); more options: 'caption', 'credit', 'copyright', 'flash', 'keywords', 'orientation', and 'title' are unused in this implementation
    $fields = apply_filters('ubik_photo_meta_fields', array('created_timestamp', 'camera', 'aperture', 'shutter_speed', 'focal_length', 'iso', 'exposure', 'location', 'sizes', 'license'));
    // Fetch metadata
    $meta_raw = ubik_photo_meta_data($id, $fields);
    // Initialize the array
    $meta_filtered = array();
    // Loop through the specified fields and populate the final array; this allows for customized metadata ordering
    foreach ($fields as $field) {
        if (ubik_photo_meta_set($field, $meta_raw)) {
            $meta_filtered[$field] = $meta_raw[$field];
        }
    }
    // Return whatever we have
    return apply_filters('ubik_photo_meta', $meta_filtered, $meta_raw);
}
function ubik_photo_meta_sizes()
{
    // Get the attachment ID
    $id = ubik_photo_meta_attachment_id();
    // Exit early if necessary
    if (empty($id)) {
        return;
    }
    // Initialize links array
    $links = $dimensions = array();
    // Microdata switch
    $microdata = '';
    $microdata_id = ubik_photo_meta_microdata_id($id);
    // Limit the returned sizes to a pre-defined list; sizes will also display in this order
    $sizes = apply_filters('ubik_photo_meta_sizes', array('full', 'large', 'medium', 'thumbnail'));
    // Loop through the specified sizes and build links where avilable
    foreach ($sizes as $size) {
        // Get the current image size (returns false if unavailable)
        $image = wp_get_attachment_image_src($id, $size);
        // Conditionally add the link to the array if: 1) there's an image; 2) the image is intermediate or full; 3) there isn't already an image in the array with the same dimensions
        if (!empty($image) && ($image[3] == true || $size == 'full') && !in_array($image[1] . $image[2], $dimensions)) {
            if (!empty($microdata_id)) {
                if ($size == 'full') {
                    $microdata = ' itemprop="contentURL"';
                } elseif ($size == 'thumbnail') {
                    $microdata = ' itemprop="thumbnailURL"';
                } else {
                    $microdata = '';
                }
            }
            $links[] = '<a href="' . $image[0] . '"' . $microdata . ' rel="enclosure">' . $image[1] . apply_filters('ubik_photo_meta_sizes_times', '&#x200a;&#215;&#x200a;') . $image[2] . '</a>';
            $dimensions[] = $image[1] . $image[2];
        }
    }
    return apply_filters('ubik_photo_meta_sizes_links', $links);
}