-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CDN - remove filetypes to replace if setting is disabled #800
base: dev
Are you sure you want to change the base?
CDN - remove filetypes to replace if setting is disabled #800
Conversation
src/admin-settings.cls.php
Outdated
// Remove from MAPPING FILETYPE IMAGES/CSS/JS if settings are disabled | ||
$remove_type = array(); | ||
if (empty($data2[$k][self::CDN_MAPPING_INC_IMG])) { | ||
$remove_type = array_merge($remove_type, array('jpg', 'jpeg', 'png', 'gif', 'svg', 'webp', 'avif')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These types should be always removed, no matter if the option checked or not. Append them dynamically in cdn::init()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the conditions
9d2f0f8
to
5678ab8
Compare
@hi-hai added the rewrite to happen on content html |
src/admin-settings.cls.php
Outdated
@@ -117,6 +117,22 @@ public function save($raw_data) | |||
foreach ($data as $k => $v) { | |||
if ($child == self::CDN_MAPPING_FILETYPE) { | |||
$v = Utility::sanitize_lines($v); | |||
|
|||
// Remove from MAPPING FILETYPE extensions for IMAGES, CSS, JS | |||
$remove_type = array('jpg', 'jpeg', 'png', 'gif', 'svg', 'webp', 'avif', 'css', 'js'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
give it a filter plz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
src/admin-settings.cls.php
Outdated
|
||
// Remove from MAPPING FILETYPE extensions for IMAGES, CSS, JS | ||
$remove_type = array('jpg', 'jpeg', 'png', 'gif', 'svg', 'webp', 'avif', 'css', 'js'); | ||
$temp = array_filter($v, function ($i_v) use ($remove_type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a simple loop to unset it, easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/admin-settings.cls.php
Outdated
$leave_value = true; | ||
|
||
foreach ($remove_type as $remove) { | ||
if (strpos($i_v, $remove) !== false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not correct. Need to full match
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed with above
src/cdn.cls.php
Outdated
@@ -209,9 +209,28 @@ private function _finalize() | |||
$this->_replace_inline_css(); | |||
} | |||
|
|||
// Temporary add file types to mapping filetype rewrite |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should append them in init()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved
'.css', | ||
'.js', | ||
)); | ||
$v = array_diff($v, $remove_type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
1bed608
to
a692a9e
Compare
@hi-hai fixed the file types to include images. |
In CDN, at mapping settings if Include Images/CSS/JS is disabled it removes the file types from "Include File Types" setting.
Before:
After save: