ID.php
10 years ago
actions.php
10 years ago
alternate-text.php
10 years ago
attached-to.php
10 years ago
available-sizes.php
10 years ago
caption.php
10 years ago
description.php
10 years ago
dimensions.php
10 years ago
exif-data.php
10 years ago
file-name.php
10 years ago
file-size.php
10 years ago
full-path.php
10 years ago
height.php
10 years ago
mime-type.php
10 years ago
width.php
10 years ago
available-sizes.php
69 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * CPAC_Column_Media_Available_Sizes |
| 5 | * |
| 6 | * @since 2.0 |
| 7 | */ |
| 8 | class CPAC_Column_Media_Available_Sizes extends CPAC_Column { |
| 9 | |
| 10 | /** |
| 11 | * @see CPAC_Column::init() |
| 12 | * @since 2.2.1 |
| 13 | */ |
| 14 | public function init() { |
| 15 | |
| 16 | parent::init(); |
| 17 | |
| 18 | // Properties |
| 19 | $this->properties['type'] = 'column-available_sizes'; |
| 20 | $this->properties['label'] = __( 'Available Sizes', 'codepress-admin-columns' ); |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * @see CPAC_Column::get_value() |
| 25 | * @since 2.0 |
| 26 | */ |
| 27 | function get_value( $id ) { |
| 28 | $paths = array(); |
| 29 | |
| 30 | $meta = get_post_meta( $id, '_wp_attachment_metadata', true ); |
| 31 | |
| 32 | if ( ! isset( $meta['sizes'] ) ) |
| 33 | return false; |
| 34 | |
| 35 | // available sizes |
| 36 | if ( $intersect = array_intersect( array_keys( $meta['sizes'] ), get_intermediate_image_sizes() ) ) { |
| 37 | |
| 38 | $url = wp_get_attachment_url( $id ); |
| 39 | $filename = basename( $url ); |
| 40 | $paths[] = "<a title='{$filename}' href='{$url}'>" . __( 'full size', 'codepress-admin-columns' ) . "</a>"; |
| 41 | |
| 42 | foreach ( $intersect as $size ) { |
| 43 | $src = wp_get_attachment_image_src( $id, $size ); |
| 44 | |
| 45 | if ( ! empty( $src[0] ) ) { |
| 46 | $filename = basename( $src[0] ); |
| 47 | $paths[] = "<a title='{$filename}' href='{$src[0]}' class='available'>{$size}</a>"; |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | global $_wp_additional_image_sizes; |
| 53 | |
| 54 | if ( ! empty( $_wp_additional_image_sizes ) ) { |
| 55 | if ( isset( $_wp_additional_image_sizes['post-thumbnail'] ) ) { |
| 56 | unset( $_wp_additional_image_sizes['post-thumbnail'] ); |
| 57 | } |
| 58 | |
| 59 | // image does not have these additional sizes rendered yet |
| 60 | if ( $missing = array_diff( array_keys( $_wp_additional_image_sizes), array_keys( $meta['sizes'] ) ) ) { |
| 61 | foreach ( $missing as $size ) { |
| 62 | $paths[] = "<span title='Missing size: Try regenerate thumbnails with the plugin: Force Regenerate Thumbnails' href='javascript:;' class='not-available'>{$size}</span>"; |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | return "<div class='sizes'>" . implode( '<span class="cpac-divider"></span>', $paths ) . "</div>"; |
| 68 | } |
| 69 | } |