# imagify/1.3.3/inc/admin/meta-boxes.php

Imagify Image Optimization: Optimize Images | Compress &amp; Convert to WebP/AVIF, version 1.3.3. 32 lines.

- Page: https://pluginprobe.com/plugins/imagify/1.3.3/code/inc/admin/meta-boxes.php
- Raw: https://pluginprobe.com/plugins/imagify/1.3.3/raw/inc/admin/meta-boxes.php
- Modified: 2016-01-27T15:07:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/imagify/1.3.3/code/inc/admin/meta-boxes.php#L10-L20`.

```php
<?php
defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' );

/**
 * Add a "Optimize It" button or the Imagify optimization data in the attachment submit area
 *
 * @since 1.0
 */
add_action( 'attachment_submitbox_misc_actions', '_imagify_attachment_submitbox_misc_actions', PHP_INT_MAX );
function _imagify_attachment_submitbox_misc_actions()
{
	/** This filter is documented in inc/admin/options.php */
	if ( current_user_can( apply_filters( 'imagify_capacity', 'manage_options' ) ) ) {
		global $post;
		$attachment = new Imagify_Attachment();

		if ( ! imagify_valid_key() && ! $attachment->is_optimized() ) {
			echo '<div class="misc-pub-section misc-pub-imagify"><h4>' . __( 'Imagify', 'imagify' ) . '</h4></div>';
			echo '<div class="misc-pub-section misc-pub-imagify">';
				echo __( 'Invalid API key', 'imagify' );
				echo '<br/>';
				echo '<a href="' . get_imagify_admin_url( 'options-general' ) . '">' . __( 'Check your Settings', 'imagify' ) . '</a>';
			echo '</div>';
		} elseif ( $attachment->is_optimized() || $attachment->has_error() ) {
			echo '<div class="misc-pub-section misc-pub-imagify"><h4>' . __( 'Imagify', 'imagify' ) . '</h4></div>';
			echo get_imagify_attachment_optimization_text( $post->ID );
		} else {
			$url = get_imagify_admin_url( 'manual-upload', $post->ID );
		printf( '<div class="misc-pub-section misc-pub-imagify"><a class="button-primary" href="%s">%s</a></div>', $url, __( 'Optimize', 'imagify' ) );
		}
	}
}
```
