From bf6f8f273373a1aa46891bc88c133ba22f429fc7 Mon Sep 17 00:00:00 2001 From: Sonny Le Date: Tue, 13 Aug 2024 16:52:41 +0700 Subject: [PATCH] Add Image Effect for Article Widget --- .../astroid/scss/utilities/_image_effect.scss | 3 +++ .../astroid/scss/utilities/_utilities.scss | 1 + framework/elements/articles/articles.php | 21 +++++++++++++++++++ framework/elements/articles/articles.xml | 18 ++++++++++++++++ language/en-GB/en-GB.astroid.ini | 9 ++++++++ 5 files changed, 52 insertions(+) create mode 100644 assets/vendor/astroid/scss/utilities/_image_effect.scss diff --git a/assets/vendor/astroid/scss/utilities/_image_effect.scss b/assets/vendor/astroid/scss/utilities/_image_effect.scss new file mode 100644 index 00000000..0a33f154 --- /dev/null +++ b/assets/vendor/astroid/scss/utilities/_image_effect.scss @@ -0,0 +1,3 @@ +.as-image-effect { + transition: filter 0.3s ease-in-out; +} \ No newline at end of file diff --git a/assets/vendor/astroid/scss/utilities/_utilities.scss b/assets/vendor/astroid/scss/utilities/_utilities.scss index 92251272..d9ee2553 100644 --- a/assets/vendor/astroid/scss/utilities/_utilities.scss +++ b/assets/vendor/astroid/scss/utilities/_utilities.scss @@ -1,4 +1,5 @@ @import "typography"; +@import "image_effect"; @import "width"; @import "gutters"; @import "columns"; diff --git a/framework/elements/articles/articles.php b/framework/elements/articles/articles.php index 37d3a7eb..7e2c9f9f 100644 --- a/framework/elements/articles/articles.php +++ b/framework/elements/articles/articles.php @@ -202,6 +202,20 @@ $img_border_radius = $img_border_radius !== '' ? ' ' . $img_border_radius : ''; } +// Image Effect +$enable_image_effect= $params->get('enable_image_effect', 0); +$brightness = $params->get('brightness', '100'); +$contrast = $params->get('contrast', '100'); +$saturate = $params->get('saturate', '100'); +$blur = $params->get('blur', '0'); +$hue_rotate = $params->get('hue_rotate', '0'); + +$brightness_hover = $params->get('brightness_hover', '100'); +$contrast_hover = $params->get('contrast_hover', '100'); +$saturate_hover = $params->get('saturate_hover', '100'); +$blur_hover = $params->get('blur_hover', '0'); +$hue_rotate_hover = $params->get('hue_rotate_hover', '0'); + $title_html_element = $params->get('title_html_element', 'h3'); $title_font_style = $params->get('title_font_style'); if (!empty($title_font_style)) { @@ -300,6 +314,9 @@ if ($item_image_cover && ($item->post_format !== 'video' || $video_type !== 'local')) { $media = '
'.$item->title.'
'; } + if ($enable_image_effect) { + $media = '
' . $media . '
'; + } echo '
'; if (($media_position == 'left' || $media_position == 'right') && !$item_image_cover && $layout == 'classic') { echo '
'; @@ -429,6 +446,10 @@ $style->child('.as-slideshow-media .carousel-item')->addCss('height', $min_height . 'px'); } } +if ($enable_image_effect) { + $style->child('.as-image-effect')->addCss('filter', 'brightness('.$brightness.'%) contrast('.$contrast.'%) saturate('.$saturate.'%) blur('.$blur.'px) hue-rotate('.$hue_rotate.'deg)'); + $style->child('.as-image-effect')->hover()->addCss('filter', 'brightness('.$brightness_hover.'%) contrast('.$contrast_hover.'%) saturate('.$saturate_hover.'%) blur('.$blur_hover.'px) hue-rotate('.$hue_rotate_hover.'deg)'); +} switch ($overlay_type) { case 'color': $overlay_color = Style::getColor($params->get('overlay_color', '')); diff --git a/framework/elements/articles/articles.xml b/framework/elements/articles/articles.xml index 52c752a3..4bc62bd7 100644 --- a/framework/elements/articles/articles.xml +++ b/framework/elements/articles/articles.xml @@ -356,6 +356,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/language/en-GB/en-GB.astroid.ini b/language/en-GB/en-GB.astroid.ini index 22a92071..c5453f40 100644 --- a/language/en-GB/en-GB.astroid.ini +++ b/language/en-GB/en-GB.astroid.ini @@ -1407,6 +1407,15 @@ ASTROID_WIDGET_ENABLE_ICON_LINK="Enable Icon Link" ASTROID_WIDGET_MIN_HEIGHT="Min Height" ASTROID_WIDGET_NAV_COLOR="Navigation Color" ASTROID_WIDGET_OVERLAY_COLOR="Overlay Color" +ASTROID_WIDGET_ENABLE_IMAGE_EFFECT="Enable Image Effect" +ASTROID_WIDGET_IMAGE_HOVER_EFFECT="Image Hover Effect" +ASTROID_WIDGET_NORMAL_EFFECT="Normal Effect" +ASTROID_WIDGET_HOVER_EFFECT="Hover Effect" +ASTROID_WIDGET_BRIGHTNESS="Brightness" +ASTROID_WIDGET_CONTRACT="Contract" +ASTROID_WIDGET_SATURATE="Saturate" +ASTROID_WIDGET_BLUR="Blur" +ASTROID_WIDGET_HUE="Hue Rotate" ASTROID_WIDGET_OVERLAY_GRADIENT="Overlay Gradient" ASTROID_WIDGET_META_POSITION_LABEL="Meta Position" ASTROID_BEFORE_TITLE="Before Title"