function ubik_imagery_feed($id = '', $size = '', $alt = '', $align = 'none') { // The `get_image_tag` function requires a simple alignment e.g. "none", "left", etc. $align = str_replace('align', '', $align); // Size limiter for feeds $size_default = apply_filters('ubik_imagery_feed_default_size', 'medium'); $sizes_metadata = ubik_imagery_sizes_metadata(); // Default size filter applies here as well if (empty($size)) { $size = $size_default; } // Scale down images for the feed; @TODO: replace with an image that has the same aspect ratio if (isset($sizes_metadata[$size])) { if ($sizes_metadata[$size]['width'] > $sizes_metadata[$size_default]['width']) { $size = $size_default; } } // Default image element generator cribbed from WordPress core return apply_filters('ubik_imagery_feed', get_image_tag($id, $alt, $title = '', $align, $size)); }
function ubik_imagery_sizes_admin($sizes) { $sizes_builtin = ubik_imagery_sizes_builtin(); $sizes_metadata = ubik_imagery_sizes_metadata(); // Check to see if we have anything at all; if not, return the sizes exactly as they are if (!empty($sizes_metadata)) { // Unset predefined sizes (doing it this way allows for other plugins to modify the array) if (!empty($sizes_builtin)) { $sizes_builtin[] = 'full'; // Let's remove the full size; we'll add it back later foreach ($sizes_builtin as $size_builtin) { unset($sizes[$size_builtin]); } } // Initialize sizes array $sizes_array = array(); // Populate a temporary array with the information we need to generate a list of available image sizes foreach ($sizes_metadata as $name => $data) { $sizes_array[] = array('name' => $name, 'display' => ucwords(str_replace(array('-', '_'), ' ', $name)), 'width' => $data['width']); } // Sort all sizes by resolution (smallest first) usort($sizes_array, 'ubik_imagery_sizes_admin_sort'); // Loop through all image sizes and populate the sizes array foreach ($sizes_array as $size) { $sizes[$size['name']] = $size['display']; } // Unset post thumbnail size if (isset($sizes['post-thumbnail'])) { unset($sizes['post-thumbnail']); } // Add the `full` size to the end of the array $sizes['full'] = __('Full', 'ubik'); } return apply_filters('ubik_imagery_sizes_admin', $sizes); }