-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added media switcher to allow the user the use the default image inst…
…ead of webp
- Loading branch information
1 parent
7f94f3f
commit 9fde76c
Showing
4 changed files
with
125 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace GdWebpConverter\Providers; | ||
|
||
class FieldsServiceProvider implements Provider | ||
{ | ||
public function __construct() | ||
{ | ||
add_action('acf/init', [$this, 'gd_webp_converter_fields']); | ||
} | ||
|
||
public function register() | ||
{ | ||
// | ||
} | ||
|
||
public function gd_webp_converter_fields() { | ||
if (!function_exists('acf_add_options_page')) { | ||
return; | ||
} | ||
|
||
acf_add_local_field_group(array( | ||
'key' => 'group_gd_webp_converter_media_settings', | ||
'title' => 'GD Webp Media Settings', | ||
'fields' => array (), | ||
'position' => 'normal', | ||
'menu_order' => 0, | ||
'label_placement' => 'top', | ||
'style' => 'default', | ||
'active' => true, | ||
'description' => '', | ||
'location' => array ( | ||
array ( | ||
array ( | ||
'param' => 'attachment', | ||
'operator' => '==', | ||
'value' => 'image/jpeg', | ||
), | ||
), | ||
array( | ||
array( | ||
'param' => 'attachment', | ||
'operator' => '==', | ||
'value' => 'image/png', | ||
), | ||
), | ||
), | ||
)); | ||
|
||
acf_add_local_field(array( | ||
'key' => 'field_gd_webp_converter_media_settings_gd_webp_mime_type_switcher', | ||
'label' => 'Use original image?', | ||
'name' => 'gd_webp_mime_type_switcher', | ||
'type' => 'true_false', | ||
'required' => 0, | ||
'wrapper' => [ | ||
'width' => '', | ||
'class' => '', | ||
'id' => '', | ||
], | ||
'default_value' => 0, | ||
'ui' => 1, | ||
'ui_on_text' => '', | ||
'ui_off_text' => '', | ||
'parent' => 'group_gd_webp_converter_media_settings', | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters