Changeset 2712664
- Timestamp:
- 04/21/2022 09:15:10 AM (4 years ago)
- Location:
- imageflux
- Files:
-
- 7 edited
- 9 copied
-
assets/screenshot-5.png (modified) (previous)
-
tags/1.0.2 (copied) (copied from imageflux/trunk)
-
tags/1.0.2/classes (copied) (copied from imageflux/trunk/classes)
-
tags/1.0.2/css (copied) (copied from imageflux/trunk/css)
-
tags/1.0.2/imageflux.php (copied) (copied from imageflux/trunk/imageflux.php) (11 diffs)
-
tags/1.0.2/js (copied) (copied from imageflux/trunk/js)
-
tags/1.0.2/models (copied) (copied from imageflux/trunk/models)
-
tags/1.0.2/models/ImagefluxDiffSetting.php (modified) (1 diff)
-
tags/1.0.2/readme.txt (copied) (copied from imageflux/trunk/readme.txt) (3 diffs)
-
tags/1.0.2/templates (copied) (copied from imageflux/trunk/templates)
-
tags/1.0.2/templates/diff-settings.php (modified) (1 diff)
-
tags/1.0.2/templates/token-settings.php (copied) (copied from imageflux/trunk/templates/token-settings.php)
-
trunk/imageflux.php (modified) (11 diffs)
-
trunk/models/ImagefluxDiffSetting.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/templates/diff-settings.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
imageflux/tags/1.0.2/imageflux.php
r2644355 r2712664 4 4 Plugin URI: 5 5 Description: WordPressサイトの画像を一括で最適化・軽量化し、CDNを通して配信します。 6 Version: 1.0. 17 Author: SAKURA Internet Inc.6 Version: 1.0.2 7 Author: SAKURA internet Inc. 8 8 Author URI: https://www.sakura.ad.jp/services/imageflux/ 9 9 License: GPLv2 … … 26 26 // 画像置換処理 27 27 add_filter('the_content', 'ImageFluxPage::doProcess'); 28 // ヘッダー(アイキャッチ部分の)画像置換 29 add_filter('post_thumbnail_html', 'ImageFluxPage::doProcess' ); 28 30 29 31 /** … … 149 151 $transfer_view_datas = []; 150 152 153 if (!isset($transfer_data_origins['invoices'])) { 154 include __DIR__ . '/templates/dashboard.php'; 155 return; 156 } 157 151 158 foreach ($transfer_data_origins['invoices'] as $transfer_data) { 152 159 … … 415 422 'allow_extension_gif' => sanitize_text_field($_POST['allow_extension_gif']), 416 423 'is_auto_resize' => sanitize_text_field($_POST['is_auto_resize']), 424 'auto_resize_pc' => sanitize_text_field($_POST['auto_resize_pc']), 425 'auto_resize_mobile' => sanitize_text_field($_POST['auto_resize_mobile']), 417 426 'quality' => sanitize_text_field($_POST['quality']), 418 427 'exif' => sanitize_text_field($_POST['exif']), … … 647 656 $basic = new ImagefluxBasicSetting(); 648 657 658 if (!$basic->get('api_token')) { 659 return $content; 660 } 661 649 662 $kind = (int)$basic->get('kind'); 650 663 // 種別判定 … … 660 673 661 674 $params = self::makeUrlParams(); 675 $params_retina = self::makeUrlParams(true); 662 676 663 677 foreach ($image_tags as $index => $image_tag) { … … 673 687 $file_path = str_replace(['https://', 'http://'], '', $file_path); 674 688 // 署名 689 $file_path_retina = self::addSignature("/c", $params_retina, $file_path); 675 690 $file_path = self::addSignature("/c", $params, $file_path); 676 691 677 692 $imageflux_src = $origin_url . $file_path; 693 $imageflux_src_retina = $origin_url . $file_path_retina; 678 694 679 695 $pattern = '/<img([^>]*)src=[\"|\']' . str_replace('/', '\/', $image_src) . '[\"|\']/'; 680 696 681 $replace = '<img$1src ="' . $imageflux_src . '"';697 $replace = '<img$1srcset="' . $imageflux_src . ' 1x,'. $imageflux_src_retina . ' 2x"'; 682 698 $content = preg_replace($pattern, $replace, $content); 683 699 } … … 694 710 695 711 $params = self::makeUrlParams(); 712 $params_retina = self::makeUrlParams(true); 696 713 697 714 foreach ($image_tags as $index => $image_tag) { … … 706 723 707 724 $file_path = str_replace(['https://', 'http://'], '', $file_path); 725 $file_path_retina = self::addSignature("/c", $params_retina, $file_path); 708 726 // 署名 709 727 $file_path = self::addSignature("/c", $params, $file_path); 710 728 711 729 $imageflux_src = $origin_url . $file_path; 730 $imageflux_src_retina = $origin_url . $file_path_retina; 712 731 713 732 $pattern = '/<img([^>]*)src=[\"|\']' . str_replace('/', '\/', $image_src) . '[\"|\']/'; 714 733 715 $replace = '<img$1src ="' . $imageflux_src . '"';734 $replace = '<img$1srcset="' . $imageflux_src . ' 1x,'. $imageflux_src_retina . ' 2x"'; 716 735 $content = preg_replace($pattern, $replace, $content); 717 736 } … … 746 765 * @return string 747 766 */ 748 public static function makeUrlParams( )767 public static function makeUrlParams($is_retina = false) 749 768 { 750 769 $params_str = "/"; … … 774 793 $is_auto_resize = ImageFluxManagement::getOption('is_auto_resize'); 775 794 795 $auto_resize_pc = ImageFluxManagement::getOption('auto_resize_pc') ?? 1024; 796 $auto_resize_mobile = ImageFluxManagement::getOption('auto_resize_mobile') ?? 750; 797 798 if ($is_retina) { 799 $auto_resize_pc *= 2; 800 $auto_resize_mobile *= 2; 801 } 802 776 803 if ($is_auto_resize === null || (int)$is_auto_resize === 1) { 777 $width = self::isMobile() ? 750 : 1024;804 $width = self::isMobile() ? $auto_resize_mobile : $auto_resize_pc; 778 805 779 806 $params_str .= "w=" . $width . ","; -
imageflux/tags/1.0.2/models/ImagefluxDiffSetting.php
r2643143 r2712664 12 12 'allow_extension_gif', 13 13 'is_auto_resize', 14 'auto_resize_pc', 15 'auto_resize_mobile', 14 16 'quality', 15 17 'exif' -
imageflux/tags/1.0.2/readme.txt
r2644355 r2712664 5 5 Tested up to: 5.8.2 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 17 Stable tag: 1.0.2 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 123 123 124 124 == Changelog == 125 = 1.0.2 = 126 * アイキャッチ画像の変換に対応 127 * 「端末に応じた画像サイズに自動変換」が有効な際、ユーザーエージェントに応じて画像サイズの設定が可能 128 * 「端末に応じた画像サイズに自動変換」が有効な際、Retinaディスプレイでは設定の2倍の画像サイズで配信する 125 129 = 1.0.1 = 126 130 * 表示テキストの修正 … … 129 133 = 0.9.0 = 130 134 * テストリリース 131 -
imageflux/tags/1.0.2/templates/diff-settings.php
r2643143 r2712664 49 49 </p> 50 50 <p> 51 <label for="auto_resize_pc">PCの自動変換サイズ</label> 52 <input type="number" name="auto_resize_pc" value="<?php echo esc_attr(is_null($diff->get('auto_resize_pc')) ? 1024 : (int)$diff->get('auto_resize_pc')) ?>" min="0" /> 53 </p> 54 <p> 55 <label for="auto_resize_mobile">モバイル端末の自動変換サイズ</label> 56 <input type="number" name="auto_resize_mobile" value="<?php echo esc_attr(is_null($diff->get('auto_resize_mobile')) ? 750 : (int)$diff->get('auto_resize_mobile')) ?>" min="0" /> 57 </p> 58 <p> 51 59 <label for="quality">クオリティ指定:</label> 52 60 <input type="number" id="quality" name="quality" -
imageflux/trunk/imageflux.php
r2644355 r2712664 4 4 Plugin URI: 5 5 Description: WordPressサイトの画像を一括で最適化・軽量化し、CDNを通して配信します。 6 Version: 1.0. 17 Author: SAKURA Internet Inc.6 Version: 1.0.2 7 Author: SAKURA internet Inc. 8 8 Author URI: https://www.sakura.ad.jp/services/imageflux/ 9 9 License: GPLv2 … … 26 26 // 画像置換処理 27 27 add_filter('the_content', 'ImageFluxPage::doProcess'); 28 // ヘッダー(アイキャッチ部分の)画像置換 29 add_filter('post_thumbnail_html', 'ImageFluxPage::doProcess' ); 28 30 29 31 /** … … 149 151 $transfer_view_datas = []; 150 152 153 if (!isset($transfer_data_origins['invoices'])) { 154 include __DIR__ . '/templates/dashboard.php'; 155 return; 156 } 157 151 158 foreach ($transfer_data_origins['invoices'] as $transfer_data) { 152 159 … … 415 422 'allow_extension_gif' => sanitize_text_field($_POST['allow_extension_gif']), 416 423 'is_auto_resize' => sanitize_text_field($_POST['is_auto_resize']), 424 'auto_resize_pc' => sanitize_text_field($_POST['auto_resize_pc']), 425 'auto_resize_mobile' => sanitize_text_field($_POST['auto_resize_mobile']), 417 426 'quality' => sanitize_text_field($_POST['quality']), 418 427 'exif' => sanitize_text_field($_POST['exif']), … … 647 656 $basic = new ImagefluxBasicSetting(); 648 657 658 if (!$basic->get('api_token')) { 659 return $content; 660 } 661 649 662 $kind = (int)$basic->get('kind'); 650 663 // 種別判定 … … 660 673 661 674 $params = self::makeUrlParams(); 675 $params_retina = self::makeUrlParams(true); 662 676 663 677 foreach ($image_tags as $index => $image_tag) { … … 673 687 $file_path = str_replace(['https://', 'http://'], '', $file_path); 674 688 // 署名 689 $file_path_retina = self::addSignature("/c", $params_retina, $file_path); 675 690 $file_path = self::addSignature("/c", $params, $file_path); 676 691 677 692 $imageflux_src = $origin_url . $file_path; 693 $imageflux_src_retina = $origin_url . $file_path_retina; 678 694 679 695 $pattern = '/<img([^>]*)src=[\"|\']' . str_replace('/', '\/', $image_src) . '[\"|\']/'; 680 696 681 $replace = '<img$1src ="' . $imageflux_src . '"';697 $replace = '<img$1srcset="' . $imageflux_src . ' 1x,'. $imageflux_src_retina . ' 2x"'; 682 698 $content = preg_replace($pattern, $replace, $content); 683 699 } … … 694 710 695 711 $params = self::makeUrlParams(); 712 $params_retina = self::makeUrlParams(true); 696 713 697 714 foreach ($image_tags as $index => $image_tag) { … … 706 723 707 724 $file_path = str_replace(['https://', 'http://'], '', $file_path); 725 $file_path_retina = self::addSignature("/c", $params_retina, $file_path); 708 726 // 署名 709 727 $file_path = self::addSignature("/c", $params, $file_path); 710 728 711 729 $imageflux_src = $origin_url . $file_path; 730 $imageflux_src_retina = $origin_url . $file_path_retina; 712 731 713 732 $pattern = '/<img([^>]*)src=[\"|\']' . str_replace('/', '\/', $image_src) . '[\"|\']/'; 714 733 715 $replace = '<img$1src ="' . $imageflux_src . '"';734 $replace = '<img$1srcset="' . $imageflux_src . ' 1x,'. $imageflux_src_retina . ' 2x"'; 716 735 $content = preg_replace($pattern, $replace, $content); 717 736 } … … 746 765 * @return string 747 766 */ 748 public static function makeUrlParams( )767 public static function makeUrlParams($is_retina = false) 749 768 { 750 769 $params_str = "/"; … … 774 793 $is_auto_resize = ImageFluxManagement::getOption('is_auto_resize'); 775 794 795 $auto_resize_pc = ImageFluxManagement::getOption('auto_resize_pc') ?? 1024; 796 $auto_resize_mobile = ImageFluxManagement::getOption('auto_resize_mobile') ?? 750; 797 798 if ($is_retina) { 799 $auto_resize_pc *= 2; 800 $auto_resize_mobile *= 2; 801 } 802 776 803 if ($is_auto_resize === null || (int)$is_auto_resize === 1) { 777 $width = self::isMobile() ? 750 : 1024;804 $width = self::isMobile() ? $auto_resize_mobile : $auto_resize_pc; 778 805 779 806 $params_str .= "w=" . $width . ","; -
imageflux/trunk/models/ImagefluxDiffSetting.php
r2643143 r2712664 12 12 'allow_extension_gif', 13 13 'is_auto_resize', 14 'auto_resize_pc', 15 'auto_resize_mobile', 14 16 'quality', 15 17 'exif' -
imageflux/trunk/readme.txt
r2644355 r2712664 5 5 Tested up to: 5.8.2 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 17 Stable tag: 1.0.2 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 123 123 124 124 == Changelog == 125 = 1.0.2 = 126 * アイキャッチ画像の変換に対応 127 * 「端末に応じた画像サイズに自動変換」が有効な際、ユーザーエージェントに応じて画像サイズの設定が可能 128 * 「端末に応じた画像サイズに自動変換」が有効な際、Retinaディスプレイでは設定の2倍の画像サイズで配信する 125 129 = 1.0.1 = 126 130 * 表示テキストの修正 … … 129 133 = 0.9.0 = 130 134 * テストリリース 131 -
imageflux/trunk/templates/diff-settings.php
r2643143 r2712664 49 49 </p> 50 50 <p> 51 <label for="auto_resize_pc">PCの自動変換サイズ</label> 52 <input type="number" name="auto_resize_pc" value="<?php echo esc_attr(is_null($diff->get('auto_resize_pc')) ? 1024 : (int)$diff->get('auto_resize_pc')) ?>" min="0" /> 53 </p> 54 <p> 55 <label for="auto_resize_mobile">モバイル端末の自動変換サイズ</label> 56 <input type="number" name="auto_resize_mobile" value="<?php echo esc_attr(is_null($diff->get('auto_resize_mobile')) ? 750 : (int)$diff->get('auto_resize_mobile')) ?>" min="0" /> 57 </p> 58 <p> 51 59 <label for="quality">クオリティ指定:</label> 52 60 <input type="number" id="quality" name="quality"
Note: See TracChangeset
for help on using the changeset viewer.