Skip to content

Commit

Permalink
Dev 1.4.0 (#56)
Browse files Browse the repository at this point in the history
* code cleanup, library updates, add webp to supported files

* adding conditional to determine file extension using new image_editor_output_format hook (#54)

* fix typo, add benjibee to readme

* fix refactoring bugs

Co-authored-by: Volkmar Kantor <volkmar.kantor@gmx.de>
Co-authored-by: Benji Bilheimer <git@benjibee.com>
  • Loading branch information
3 people committed Sep 1, 2021
1 parent 888c6b6 commit b76120d
Show file tree
Hide file tree
Showing 18 changed files with 2,410 additions and 18,301 deletions.
5 changes: 0 additions & 5 deletions __dev/babel.config.js

This file was deleted.

20,523 changes: 2,326 additions & 18,197 deletions __dev/package-lock.json

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions __dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@
"build": "vue-cli-service build",
"export": "node export.js"
},
"babel": {
"presets": [
"@vue/cli-plugin-babel/preset"
]
},
"dependencies": {
"core-js": "^3.6.5",
"cropperjs": "^1.5.9",
"vue": "^2.6.11"
"core-js": "^3.16.4",
"cropperjs": "^1.5.12",
"vue": "^2.6.14"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/cli-plugin-babel": "^4.5.13",
"@vue/cli-service": "^4.5.13",
"copy-dir": "^1.3.0",
"node-sass": "^5.0.0",
"sass-loader": "^10.1.0",
"vue-template-compiler": "^2.6.11"
"sass": "^1.38.2",
"sass-loader": "^10.2.0",
"vue-template-compiler": "^2.6.14"
},
"browserslist": [
"> 1%",
Expand Down
16 changes: 3 additions & 13 deletions __dev/src/components/cropeditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,10 @@
import loadingcontainer from './loadingcontainer.vue';
import message from './message.vue';
export default {
components: { loadingcontainer, message },
props:{
imageId : {
required: true,
type:Number
},
posttype : {
required:false,
type:String,
default:null
}
},
components: {
loadingcontainer,
message
imageId : { required: true, type:Number },
posttype : { required:false, type:String, default:null },
},
data:() =>({
cropData : null,//
Expand Down
47 changes: 19 additions & 28 deletions __dev/src/components/loadingcontainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,40 @@
<script>
export default {
props:{
image : {
required: true,
type:String
}
},
data:function() {
return {
status:null
};
image : { required: true, type:String }
},
data: () => ({
status:null
}),
mounted() { this.setup(); },
watch:{
image:function() {
image() {
this.setup();
}
},
mounted:function() {
this.setup();
},
methods:{
setup : function() {
var that = this;
that.setStart();
setTimeout(function() {
var imgLoad = imagesLoaded( that.$el );
setup() {
this.setStart();
setTimeout(() => {
var imgLoad = imagesLoaded( this.$el );
imgLoad
.once('done',function() {
if(that.status!=='failed') {
that.setComplete();
.once('done',() => {
if(this.status!=='failed') {
this.setComplete();
}
})
.once('fail',function() {
that.setFailed();
})
;
.once('fail',() => {
this.setFailed();
});
},300);
},
setComplete : function() {
setComplete() {
this.status = 'completed';
},
setStart : function() {
setStart() {
this.status = 'loading';
},
setFailed : function() {
setFailed() {
this.status = 'failed';
}
}
Expand Down
10 changes: 4 additions & 6 deletions __dev/src/components/message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
<script>
export default {
props:{},
data:function() {
return {
closed:false
};
},
data:() => ({
closed:false
}),
methods:{
close : function() {
close() {
this.closed = true;
}
}
Expand Down
21 changes: 8 additions & 13 deletions __dev/src/components/settingsscreen.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div>
<div v-if="settingsData">
<div class="cptSettingsPostListDescription">{{settingsData.lang.choose_image_sizes}}</div>

<ul class="cptSettingsPostList">
Expand Down Expand Up @@ -34,23 +34,18 @@
<script>
export default {
props: {
settings: {
required: true
},
settings: { required: true },
},
components: {},
data: function () {
return {
settingsData: JSON.parse(this.settings)
};
},
mounted: function () { },
computed: {},
data:() => ({
settingsData: null,
}),
mounted() { this.settingsData = JSON.parse(this.settings); },
methods: {
isButtonHiddenOnPostType : function(postType) {
isButtonHiddenOnPostType(postType) {
return (this.settingsData.options && this.settingsData.options.hide_post_type && this.settingsData.options.hide_post_type[postType] === "1");
},
isImageSizeHidden : function(postType,imageSize) {
isImageSizeHidden(postType,imageSize) {
return (this.settingsData.options && this.settingsData.options.hide_size && this.settingsData.options.hide_size[postType] && this.settingsData.options.hide_size[postType][imageSize] === "1");
}
}
Expand Down
2 changes: 1 addition & 1 deletion __dev/src/native/init.clickhandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Create Listener for click-events with element-class ".cropThumbnailsLink".
* Open the modal box.
*/
jQuery(document).ready(function($) {
jQuery(function($) {
$(document).on('click', '.cropThumbnailsLink', function(e) {
e.preventDefault();

Expand Down
3 changes: 1 addition & 2 deletions __dev/src/native/init.settingsscreen.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

import cptSettingsscreen from './../components/settingsscreen.vue'
import Vue from 'vue';
jQuery(document).ready(function ($) {
jQuery(function ($) {
if($('body.settings_page_page-cpt').length>0) {
CROP_THUMBNAILS_VUE.app = new Vue({
el: '#cpt_settings_settingsscreen',
mounted: function () {console.log('cpt_settings_settingsscreen mounted')},
components: {
cptSettingsscreen
}
Expand Down
2 changes: 1 addition & 1 deletion app/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/js/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/js/app.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions app/js/chunk-vendors.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/js/chunk-vendors.js.map

Large diffs are not rendered by default.

24 changes: 7 additions & 17 deletions crop-thumbnails.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin URI: https://wordpress.org/extend/plugins/crop-thumbnails/
* Author: Volkmar Kantor
* Author URI: https://www.totalmedial.de
* Version: 1.3.1
* Version: 1.4.0
* Description: The easy way to adjust your cropped image sizes.
*
*
Expand All @@ -26,20 +26,10 @@
*/


define('CROP_THUMBNAILS_VERSION','1.3.1');
define('CROP_THUMBNAILS_VERSION','1.4.0');


/**
* returns the WpVersion in as a float
*/
function cptGetWpVersion() {
$version = get_bloginfo('version');
$version = floatval(substr($version,0,3));
return $version;
}

include_once(__DIR__.'/functions/helper.php');
include_once(__DIR__.'/functions/settingsscreen.php');
include_once(__DIR__.'/functions/editor.php');
include_once(__DIR__.'/functions/backendpreparer.php');
include_once(__DIR__.'/functions/save.php');
include_once __DIR__.'/functions/helper.php';
include_once __DIR__.'/functions/settingsscreen.php';
include_once __DIR__.'/functions/editor.php';
include_once __DIR__.'/functions/backendpreparer.php';
include_once __DIR__.'/functions/save.php';
2 changes: 1 addition & 1 deletion functions/backendpreparer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
class CropPostThumbnailsBackendPreparer {

protected $allowedMime = ['image/jpeg','image/png'];
protected $allowedMime = ['image/webp','image/jpeg','image/png'];

public function __construct() {
if ( is_admin() ) {
Expand Down
11 changes: 11 additions & 0 deletions functions/save.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,17 @@ protected static function generateFilename( $file, $imageMetadata, $w, $h, $crop
$info = pathinfo($file);
$dir = $info['dirname'];
$ext = $info['extension'];

/**
* since WordPress 5.8 the image extension / MIME type may differ from that of the
* original file so we'll use the below hook to check if any defaults are overwritten.
*/
$outputFormats = apply_filters('image_editor_output_format', [], $file);
$fileTypeInformations = wp_check_filetype($file);
if(isset($outputFormats[$fileTypeInformations['type']])) {
$ext = array_search($outputFormats[$fileTypeInformations['type']], wp_get_mime_types(), true);
}

$name = wp_basename($file, '.'.$ext);
if(!empty($imageMetadata['original_image'])) {
$name = wp_basename($imageMetadata['original_image'], '.'.$ext);
Expand Down
10 changes: 8 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Contributors: volkmar-kantor
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=volkmar%2ekantor%40gmx%2ede&lc=DE&item_name=Volkmar%20Kantor%20%2d%20totalmedial%2ede&item_number=crop%2dthumbnails&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
Tags: post-thumbnails, images, media library
Requires at least: 4.6
Tested up to: 5.7.0
Tested up to: 5.8.0
Requires PHP: 5.6.0
Stable tag: 1.3.1
Stable tag: 1.4.0
License: GPL v3
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -124,6 +124,12 @@ If you fork and planning to publish the forked plugin, please contact me.
5. Quicktest on settings-page, to check if your system is correct setup.

== Changelog ==
= 1.4.0 =
* its possible to crop webp files with the plugin
* library updates
* code cleanup
* add fix for using replacement MIME-type specified for sub-sizes (thanks to https://github.com/benjibee - https://github.com/vollyimnetz/crop-thumbnails/issues/55)

= 1.3.1 =
* crop-editor: if grouped, the notification for not yet cropped image-sizes now is visible if at least one of the images in the group is not yet cropped
* fix bug on settings page (noticible only on strict configured php environments)
Expand Down

0 comments on commit b76120d

Please sign in to comment.