Skip to content

Instantly share code, notes, and snippets.

@incrize
Created July 23, 2019 06:26
Show Gist options
  • Save incrize/fba5ead2ca1bdfb185e04e59cbf44929 to your computer and use it in GitHub Desktop.
Save incrize/fba5ead2ca1bdfb185e04e59cbf44929 to your computer and use it in GitHub Desktop.
app/addons/watermarksfunc.php.diff
diff --git a/_docs/developer_changes/patch.md b/_docs/developer_changes/patch.md
index 8bb9158355..ecea49b9cb 100644
--- a/_docs/developer_changes/patch.md
+++ b/_docs/developer_changes/patch.md
@@ -15,3 +15,8 @@
-fn_set_hook('clone_product_options_post', $from_product_id, $to_product_id, $from_global_option_id);
+fn_set_hook('clone_product_options_post', $from_product_id, $to_product_id, $from_global_option_id, $change_options, $change_variants);
```
+
+```
+-fn_set_hook('generate_thumbnail_post', $th_filename, $lazy);
++fn_set_hook('generate_thumbnail_post', $th_filename, $lazy, $image_path, $width, $height);
+```
\ No newline at end of file
diff --git a/app/addons/watermarks/func.php b/app/addons/watermarks/func.php
index ef7231336b..5f09ac709b 100644
--- a/app/addons/watermarks/func.php
+++ b/app/addons/watermarks/func.php
@@ -274,7 +274,7 @@ function fn_is_watermarks_enabled($company_id = null)
return $enabled;
}
-function fn_watermarks_generate_thumbnail_post(&$relative_path, &$lazy)
+function fn_watermarks_generate_thumbnail_post(&$relative_path, &$lazy, $source_relative_path)
{
static $init_cache = false;
@@ -299,7 +299,13 @@ function fn_watermarks_generate_thumbnail_post(&$relative_path, &$lazy)
$image_data = Registry::get($cache_name . '.' . $key);
if (empty($image_data)) {
- $image_data = db_get_row("SELECT l.* FROM ?:images AS i, ?:images_links AS l WHERE (l.image_id = i.image_id OR detailed_id = i.image_id) AND image_path LIKE ?l", $image_name . '.%');
+ $source_path_info = fn_pathinfo($source_relative_path);
+
+ $image_data = db_get_row(
+ 'SELECT l.* FROM ?:images AS i, ?:images_links AS l'
+ . ' WHERE (l.image_id = i.image_id OR detailed_id = i.image_id) AND image_path = ?s',
+ $source_path_info['basename']
+ );
if (empty($image_data)) {
return true;
diff --git a/app/functions/fn.images.php b/app/functions/fn.images.php
index 52ad303b77..560e827549 100644
--- a/app/functions/fn.images.php
+++ b/app/functions/fn.images.php
@@ -1038,10 +1038,13 @@ function fn_generate_thumbnail($image_path, $width, $height = 0, $lazy = false,
/**
* Actions after thumbnail generate
*
- * @param string $th_filename Thumbnail path
- * @param string $lazy lazy generation - returns script URL that generates thumbnail
+ * @param string $th_filename Thumbnail path
+ * @param string $lazy lazy generation - returns script URL that generates thumbnail
+ * @param string $image_path Path to image
+ * @param int $width Width of thumbnail
+ * @param int $height Height of thumbnail
*/
- fn_set_hook('generate_thumbnail_post', $th_filename, $lazy);
+ fn_set_hook('generate_thumbnail_post', $th_filename, $lazy, $image_path, $width, $height);
if (!$return_rel_path && $th_filename) {
$th_filename = Storage::instance('images')->getUrl($th_filename);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment