Skip to content
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: 17 additions & 0 deletions resources/js/components/assets/Editor/CropEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const showConfirmation = ref(false);
const uploading = ref(false);
const pendingBlob = ref(null);
const pendingMimeType = ref(null);
const cropDimensions = ref(null);

const aspectRatios = ref(Statamic.$config.get('cropAspectRatios') || []);

Expand Down Expand Up @@ -67,6 +68,7 @@ function resetState() {
uploading.value = false;
pendingBlob.value = null;
pendingMimeType.value = null;
cropDimensions.value = null;
}

function destroyCropper() {
Expand Down Expand Up @@ -118,9 +120,17 @@ function createCropper(imageElement) {
cropstart: onCropStart,
cropmove: onCropMove,
cropend: onCropEnd,
crop: onCrop,
});
}

function onCrop(event) {
cropDimensions.value = {
width: Math.round(event.detail.width),
height: Math.round(event.detail.height),
};
}

function onCropStart() {
const cropBoxData = cropper.value.getCropBoxData();
initialCropBoxCenter.value = {
Expand Down Expand Up @@ -446,6 +456,13 @@ function close() {
<div class="h-full w-full min-h-0 flex items-center justify-center overflow-hidden">
<img ref="image" :src="asset.preview" :crossorigin="crossOrigin" :alt="__('Image to crop')" class="max-w-full max-h-full" @error="onImageError" />
</div>
<div
v-if="cropDimensions"
class="absolute top-5 end-5 z-10 rounded-md bg-gray-900/75 px-2 py-1 text-xs font-medium text-white tabular-nums pointer-events-none"
:aria-label="__('Dimensions')"
v-text="__('messages.width_x_height', { width: cropDimensions.width, height: cropDimensions.height })"
/>

</div>

<!-- Footer -->
Expand Down
Loading