From de6218f6dd7dc719864955513c454562ace03e88 Mon Sep 17 00:00:00 2001 From: Rene Kreijveld Date: Thu, 3 Aug 2017 11:59:49 +0200 Subject: [PATCH] Added Crop option --- .../en-GB.plg_system_rsfpimageresize.ini | 3 +- .../nl-NL.plg_system_rsfpimageresize.ini | 3 +- .../plg_rsfp_imageresize/rsfpimageresize.php | 164 +++++++++++++++++- .../plg_rsfp_imageresize/rsfpimageresize.xml | 2 +- source/plg_rsfp_imageresize/script.php | 2 +- .../sql/mysql/install.sql | 7 +- 6 files changed, 169 insertions(+), 12 deletions(-) mode change 100755 => 100644 source/plg_rsfp_imageresize/language/en-GB/en-GB.plg_system_rsfpimageresize.ini mode change 100755 => 100644 source/plg_rsfp_imageresize/language/nl-NL/nl-NL.plg_system_rsfpimageresize.ini diff --git a/source/plg_rsfp_imageresize/language/en-GB/en-GB.plg_system_rsfpimageresize.ini b/source/plg_rsfp_imageresize/language/en-GB/en-GB.plg_system_rsfpimageresize.ini old mode 100755 new mode 100644 index 22ac571..30ec34e --- a/source/plg_rsfp_imageresize/language/en-GB/en-GB.plg_system_rsfpimageresize.ini +++ b/source/plg_rsfp_imageresize/language/en-GB/en-GB.plg_system_rsfpimageresize.ini @@ -13,4 +13,5 @@ RSFP_IMAGERESIZE_DO_MD_LABEL="Create medium" RSFP_IMAGERESIZE_LG="Large" RSFP_IMAGERESIZE_DO_LG_LABEL="Create large" RSFP_IMAGERESIZE_WIDTH="Width" -RSFP_IMAGERESIZE_HEIGHT="Height" \ No newline at end of file +RSFP_IMAGERESIZE_HEIGHT="Height" +RSFP_IMAGERESIZE_CROP_LABEL="Crop" \ No newline at end of file diff --git a/source/plg_rsfp_imageresize/language/nl-NL/nl-NL.plg_system_rsfpimageresize.ini b/source/plg_rsfp_imageresize/language/nl-NL/nl-NL.plg_system_rsfpimageresize.ini old mode 100755 new mode 100644 index 887042f..97a62b3 --- a/source/plg_rsfp_imageresize/language/nl-NL/nl-NL.plg_system_rsfpimageresize.ini +++ b/source/plg_rsfp_imageresize/language/nl-NL/nl-NL.plg_system_rsfpimageresize.ini @@ -13,4 +13,5 @@ RSFP_IMAGERESIZE_DO_MD_LABEL="Maak middel" RSFP_IMAGERESIZE_LG="Groot" RSFP_IMAGERESIZE_DO_LG_LABEL="Maak groot" RSFP_IMAGERESIZE_WIDTH="Breedte" -RSFP_IMAGERESIZE_HEIGHT="Hoogte" \ No newline at end of file +RSFP_IMAGERESIZE_HEIGHT="Hoogte" +RSFP_IMAGERESIZE_CROP_LABEL="Crop" \ No newline at end of file diff --git a/source/plg_rsfp_imageresize/rsfpimageresize.php b/source/plg_rsfp_imageresize/rsfpimageresize.php index 3036e6d..e5c591a 100755 --- a/source/plg_rsfp_imageresize/rsfpimageresize.php +++ b/source/plg_rsfp_imageresize/rsfpimageresize.php @@ -1,6 +1,6 @@ 0 || $tn_height > 0) && $do_tn == 1) { - $image->resizeToBestFit($tn_width, $tn_height); + if ($tn_crop == 1) + { + $image->crop($tn_width, $tn_height); + } + else + { + $image->resizeToBestFit($tn_width, $tn_height); + } $dst_width = floor($image->getDestWidth()); $dst_height = floor($image->getDestHeight()); $image->save($upload["dirname"] . '/' . $upload["filename"] . '-tn.' . $upload["extension"]); @@ -85,7 +97,14 @@ public function rsfp_f_onAfterFileUpload($params) // Extra small if (($xs_width > 0 || $xs_height > 0) && $do_xs == 1) { - $image->resizeToBestFit($xs_width, $xs_height); + if ($xs_crop == 1) + { + $image->crop($xs_width, $xs_height); + } + else + { + $image->resizeToBestFit($xs_width, $xs_height); + } $dst_width = floor($image->getDestWidth()); $dst_height = floor($image->getDestHeight()); $image->save($upload["dirname"] . '/' . $upload["filename"] . '-xs.' . $upload["extension"]); @@ -95,7 +114,14 @@ public function rsfp_f_onAfterFileUpload($params) // Small if (($sm_width > 0 || $sm_height > 0) && $do_sm == 1) { - $image->resizeToBestFit($sm_width, $sm_height); + if ($sm_crop == 1) + { + $image->crop($sm_width, $sm_height); + } + else + { + $image->resizeToBestFit($sm_width, $sm_height); + } $dst_width = floor($image->getDestWidth()); $dst_height = floor($image->getDestHeight()); $image->save($upload["dirname"] . '/' . $upload["filename"] . '-sm.' . $upload["extension"]); @@ -105,7 +131,14 @@ public function rsfp_f_onAfterFileUpload($params) // Medium if (($md_width > 0 || $md_height > 0) && $do_md == 1) { - $image->resizeToBestFit($md_width, $md_height); + if ($md_crop == 1) + { + $image->crop($md_width, $md_height); + } + else + { + $image->resizeToBestFit($md_width, $md_height); + } $dst_width = floor($image->getDestWidth()); $dst_height = floor($image->getDestHeight()); $image->save($upload["dirname"] . '/' . $upload["filename"] . '-md.' . $upload["extension"]); @@ -115,7 +148,14 @@ public function rsfp_f_onAfterFileUpload($params) // Large if (($lg_width > 0 || $lg_height > 0) && $do_lg == 1) { - $image->resizeToBestFit($lg_width, $lg_height); + if ($lg_crop == 1) + { + $image->crop($lg_width, $lg_height); + } + else + { + $image->resizeToBestFit($lg_width, $lg_height); + } $dst_width = floor($image->getDestWidth()); $dst_height = floor($image->getDestHeight()); $image->save($upload["dirname"] . '/' . $upload["filename"] . '-lg.' . $upload["extension"]); @@ -136,18 +176,23 @@ public function imageresizeConfigurationScreen() $do_tn = RSFormProHelper::getConfig('imgresize_do_tn'); $tn_width = RSFormProHelper::getConfig('imgresize_tn_width'); $tn_height = RSFormProHelper::getConfig('imgresize_tn_height'); + $tn_crop = RSFormProHelper::getConfig('imgresize_tn_crop'); $do_xs = RSFormProHelper::getConfig('imgresize_do_xs'); $xs_width = RSFormProHelper::getConfig('imgresize_xs_width'); $xs_height = RSFormProHelper::getConfig('imgresize_xs_height'); + $xs_crop = RSFormProHelper::getConfig('imgresize_xs_crop'); $do_sm = RSFormProHelper::getConfig('imgresize_do_sm'); $sm_width = RSFormProHelper::getConfig('imgresize_sm_width'); $sm_height = RSFormProHelper::getConfig('imgresize_sm_height'); + $sm_crop = RSFormProHelper::getConfig('imgresize_sm_crop'); $do_md = RSFormProHelper::getConfig('imgresize_do_md'); $md_width = RSFormProHelper::getConfig('imgresize_md_width'); $md_height = RSFormProHelper::getConfig('imgresize_md_height'); + $md_crop = RSFormProHelper::getConfig('imgresize_tn_crop'); $do_lg = RSFormProHelper::getConfig('imgresize_do_lg'); $lg_width = RSFormProHelper::getConfig('imgresize_lg_width'); - $lg_height = RSFormProHelper::getConfig('imgresize_lg_height'); ?> + $lg_height = RSFormProHelper::getConfig('imgresize_lg_height'); + $lg_crop = RSFormProHelper::getConfig('imgresize_tn_crop');?>

@@ -216,6 +261,27 @@ public function imageresizeConfigurationScreen() id="rsformConfig_imgresize_tn_height" value=""/>
+
+
+ +
+
+
+ /> + + /> + +
+
+

@@ -260,6 +326,27 @@ public function imageresizeConfigurationScreen() id="rsformConfig_imgresize_xs_height" value=""/>
+
+
+ +
+
+
+ /> + + /> + +
+
+

@@ -304,6 +391,27 @@ public function imageresizeConfigurationScreen() id="rsformConfig_imgresize_sm_height" value=""/>
+
+
+ +
+
+
+ /> + + /> + +
+
+

@@ -348,6 +456,27 @@ public function imageresizeConfigurationScreen() id="rsformConfig_imgresize_md_height" value=""/>
+
+
+ +
+
+
+ /> + + /> + +
+
+

@@ -392,6 +521,27 @@ public function imageresizeConfigurationScreen() id="rsformConfig_imgresize_lg_height" value=""/>
+
+
+ +
+
+
+ /> + + /> + +
+
+
GNU General Public License version 3 info@renekreijveld.nl www.renekreijveld.nl - 1.2 + 1.3 script.php diff --git a/source/plg_rsfp_imageresize/script.php b/source/plg_rsfp_imageresize/script.php index f966218..c8359c5 100755 --- a/source/plg_rsfp_imageresize/script.php +++ b/source/plg_rsfp_imageresize/script.php @@ -1,6 +1,6 @@