Skip to content
This repository has been archived by the owner on Nov 19, 2023. It is now read-only.

Noreabu — Check for at least on crop enabled image size #4

Merged
merged 1 commit into from
Dec 6, 2016
Merged
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
}
}