Skip to content

Commit

Permalink
Merge pull request tomaszsita#4 from noreabu/error-msg-no-croppable-i…
Browse files Browse the repository at this point in the history
…mages

Noreabu — Check for at least on crop enabled image size
  • Loading branch information
mcaskill authored Dec 6, 2016
2 parents 03491d4 + 9f5bb43 commit a165d1c
Showing 1 changed file with 15 additions and 2 deletions.
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 @@ -278,6 +291,6 @@ function showPreview(coords) {
}
});
</script>
<?php
<?php endif; // condition: crop enabled for at least one image size
}
}

0 comments on commit a165d1c

Please sign in to comment.