Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for at least on crop enabled image size #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/ManualImageCropEditorWindow.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,25 @@ public function renderWindow() {
$sizesSettings = MicSettingsPage::getSettings();
?>
<div class="mic-editor-wrapper">
<?php
global $_wp_additional_image_sizes;

// check if there are image definitions that allow cropping
$crop = false;
foreach($_wp_additional_image_sizes as $size) {
if ( $size["crop"] === true ) {
$crop = true;
}
}
if ( $crop === false ) : ?>
<h3><?php echo __('No available image size has "crop" enabled', 'microp'); ?></h3>
<p><?php echo __('Enable in a plugin/theme with either: add_image_size(x,y,<strong>true</strong>) or set_post_thumbnail_size(x,y,<strong>true</strong>)', 'microp'); ?></p>
<?php else : ?>
<h4>
<?php _e('Pick the image size:','microp'); ?>
</h4>
<h2 class="nav-tab-wrapper">
<?php
global $_wp_additional_image_sizes;

$imageSizes = get_intermediate_image_sizes();

Expand Down Expand Up @@ -283,6 +296,6 @@ function showPreview(coords) {
}
});
</script>
<?php
<?php endif; // condition: crop enabled for at least one image size
}
}