Plugin Directory

Changeset 2712664


Ignore:
Timestamp:
04/21/2022 09:15:10 AM (4 years ago)
Author:
imageflux
Message:

Tag1.0.2

Location:
imageflux
Files:
7 edited
9 copied

Legend:

Unmodified
Added
Removed
  • imageflux/tags/1.0.2/imageflux.php

    r2644355 r2712664  
    44  Plugin URI:
    55  Description: WordPressサイトの画像を一括で最適化・軽量化し、CDNを通して配信します。
    6   Version: 1.0.1
    7   Author: SAKURA Internet Inc.
     6  Version: 1.0.2
     7  Author: SAKURA internet Inc.
    88  Author URI: https://www.sakura.ad.jp/services/imageflux/
    99  License: GPLv2
     
    2626// 画像置換処理
    2727add_filter('the_content', 'ImageFluxPage::doProcess');
     28// ヘッダー(アイキャッチ部分の)画像置換
     29add_filter('post_thumbnail_html', 'ImageFluxPage::doProcess' );
    2830
    2931/**
     
    149151        $transfer_view_datas = [];
    150152
     153        if (!isset($transfer_data_origins['invoices'])) {
     154            include __DIR__ . '/templates/dashboard.php';
     155            return;
     156        }
     157
    151158        foreach ($transfer_data_origins['invoices'] as $transfer_data) {
    152159
     
    415422            'allow_extension_gif' => sanitize_text_field($_POST['allow_extension_gif']),
    416423            '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']),
    417426            'quality' => sanitize_text_field($_POST['quality']),
    418427            'exif' => sanitize_text_field($_POST['exif']),
     
    647656        $basic = new ImagefluxBasicSetting();
    648657
     658        if (!$basic->get('api_token')) {
     659            return $content;
     660        }
     661
    649662        $kind = (int)$basic->get('kind');
    650663        // 種別判定
     
    660673
    661674            $params = self::makeUrlParams();
     675            $params_retina = self::makeUrlParams(true);
    662676
    663677            foreach ($image_tags as $index => $image_tag) {
     
    673687                $file_path = str_replace(['https://', 'http://'], '', $file_path);
    674688                // 署名
     689                $file_path_retina = self::addSignature("/c", $params_retina, $file_path);
    675690                $file_path = self::addSignature("/c", $params, $file_path);
    676691
    677692                $imageflux_src = $origin_url . $file_path;
     693                $imageflux_src_retina = $origin_url . $file_path_retina;
    678694
    679695                $pattern = '/<img([^>]*)src=[\"|\']' . str_replace('/', '\/', $image_src) . '[\"|\']/';
    680696
    681                 $replace = '<img$1src="' . $imageflux_src . '"';
     697                $replace = '<img$1srcset="' . $imageflux_src . ' 1x,'. $imageflux_src_retina . ' 2x"';
    682698                $content = preg_replace($pattern, $replace, $content);
    683699            }
     
    694710
    695711            $params = self::makeUrlParams();
     712            $params_retina = self::makeUrlParams(true);
    696713
    697714            foreach ($image_tags as $index => $image_tag) {
     
    706723
    707724                $file_path = str_replace(['https://', 'http://'], '', $file_path);
     725                $file_path_retina = self::addSignature("/c", $params_retina, $file_path);
    708726                // 署名
    709727                $file_path = self::addSignature("/c", $params, $file_path);
    710728
    711729                $imageflux_src = $origin_url . $file_path;
     730                $imageflux_src_retina = $origin_url . $file_path_retina;
    712731
    713732                $pattern = '/<img([^>]*)src=[\"|\']' . str_replace('/', '\/', $image_src) . '[\"|\']/';
    714733
    715                 $replace = '<img$1src="' . $imageflux_src . '"';
     734                $replace = '<img$1srcset="' . $imageflux_src . ' 1x,'. $imageflux_src_retina . ' 2x"';
    716735                $content = preg_replace($pattern, $replace, $content);
    717736            }
     
    746765     * @return string
    747766     */
    748     public static function makeUrlParams()
     767    public static function makeUrlParams($is_retina = false)
    749768    {
    750769        $params_str = "/";
     
    774793        $is_auto_resize = ImageFluxManagement::getOption('is_auto_resize');
    775794
     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
    776803        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;
    778805
    779806            $params_str .= "w=" . $width . ",";
  • imageflux/tags/1.0.2/models/ImagefluxDiffSetting.php

    r2643143 r2712664  
    1212        'allow_extension_gif',
    1313        'is_auto_resize',
     14        'auto_resize_pc',
     15        'auto_resize_mobile',
    1416        'quality',
    1517        'exif'
  • imageflux/tags/1.0.2/readme.txt

    r2644355 r2712664  
    55Tested up to: 5.8.2
    66Requires PHP: 7.4
    7 Stable tag: 1.0.1
     7Stable tag: 1.0.2
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    123123
    124124== Changelog ==
     125= 1.0.2 =
     126* アイキャッチ画像の変換に対応
     127* 「端末に応じた画像サイズに自動変換」が有効な際、ユーザーエージェントに応じて画像サイズの設定が可能
     128* 「端末に応じた画像サイズに自動変換」が有効な際、Retinaディスプレイでは設定の2倍の画像サイズで配信する
    125129= 1.0.1 =
    126130* 表示テキストの修正
     
    129133= 0.9.0 =
    130134* テストリリース
    131 
  • imageflux/tags/1.0.2/templates/diff-settings.php

    r2643143 r2712664  
    4949        </p>
    5050        <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>
    5159            <label for="quality">クオリティ指定:</label>
    5260            <input type="number" id="quality" name="quality"
  • imageflux/trunk/imageflux.php

    r2644355 r2712664  
    44  Plugin URI:
    55  Description: WordPressサイトの画像を一括で最適化・軽量化し、CDNを通して配信します。
    6   Version: 1.0.1
    7   Author: SAKURA Internet Inc.
     6  Version: 1.0.2
     7  Author: SAKURA internet Inc.
    88  Author URI: https://www.sakura.ad.jp/services/imageflux/
    99  License: GPLv2
     
    2626// 画像置換処理
    2727add_filter('the_content', 'ImageFluxPage::doProcess');
     28// ヘッダー(アイキャッチ部分の)画像置換
     29add_filter('post_thumbnail_html', 'ImageFluxPage::doProcess' );
    2830
    2931/**
     
    149151        $transfer_view_datas = [];
    150152
     153        if (!isset($transfer_data_origins['invoices'])) {
     154            include __DIR__ . '/templates/dashboard.php';
     155            return;
     156        }
     157
    151158        foreach ($transfer_data_origins['invoices'] as $transfer_data) {
    152159
     
    415422            'allow_extension_gif' => sanitize_text_field($_POST['allow_extension_gif']),
    416423            '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']),
    417426            'quality' => sanitize_text_field($_POST['quality']),
    418427            'exif' => sanitize_text_field($_POST['exif']),
     
    647656        $basic = new ImagefluxBasicSetting();
    648657
     658        if (!$basic->get('api_token')) {
     659            return $content;
     660        }
     661
    649662        $kind = (int)$basic->get('kind');
    650663        // 種別判定
     
    660673
    661674            $params = self::makeUrlParams();
     675            $params_retina = self::makeUrlParams(true);
    662676
    663677            foreach ($image_tags as $index => $image_tag) {
     
    673687                $file_path = str_replace(['https://', 'http://'], '', $file_path);
    674688                // 署名
     689                $file_path_retina = self::addSignature("/c", $params_retina, $file_path);
    675690                $file_path = self::addSignature("/c", $params, $file_path);
    676691
    677692                $imageflux_src = $origin_url . $file_path;
     693                $imageflux_src_retina = $origin_url . $file_path_retina;
    678694
    679695                $pattern = '/<img([^>]*)src=[\"|\']' . str_replace('/', '\/', $image_src) . '[\"|\']/';
    680696
    681                 $replace = '<img$1src="' . $imageflux_src . '"';
     697                $replace = '<img$1srcset="' . $imageflux_src . ' 1x,'. $imageflux_src_retina . ' 2x"';
    682698                $content = preg_replace($pattern, $replace, $content);
    683699            }
     
    694710
    695711            $params = self::makeUrlParams();
     712            $params_retina = self::makeUrlParams(true);
    696713
    697714            foreach ($image_tags as $index => $image_tag) {
     
    706723
    707724                $file_path = str_replace(['https://', 'http://'], '', $file_path);
     725                $file_path_retina = self::addSignature("/c", $params_retina, $file_path);
    708726                // 署名
    709727                $file_path = self::addSignature("/c", $params, $file_path);
    710728
    711729                $imageflux_src = $origin_url . $file_path;
     730                $imageflux_src_retina = $origin_url . $file_path_retina;
    712731
    713732                $pattern = '/<img([^>]*)src=[\"|\']' . str_replace('/', '\/', $image_src) . '[\"|\']/';
    714733
    715                 $replace = '<img$1src="' . $imageflux_src . '"';
     734                $replace = '<img$1srcset="' . $imageflux_src . ' 1x,'. $imageflux_src_retina . ' 2x"';
    716735                $content = preg_replace($pattern, $replace, $content);
    717736            }
     
    746765     * @return string
    747766     */
    748     public static function makeUrlParams()
     767    public static function makeUrlParams($is_retina = false)
    749768    {
    750769        $params_str = "/";
     
    774793        $is_auto_resize = ImageFluxManagement::getOption('is_auto_resize');
    775794
     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
    776803        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;
    778805
    779806            $params_str .= "w=" . $width . ",";
  • imageflux/trunk/models/ImagefluxDiffSetting.php

    r2643143 r2712664  
    1212        'allow_extension_gif',
    1313        'is_auto_resize',
     14        'auto_resize_pc',
     15        'auto_resize_mobile',
    1416        'quality',
    1517        'exif'
  • imageflux/trunk/readme.txt

    r2644355 r2712664  
    55Tested up to: 5.8.2
    66Requires PHP: 7.4
    7 Stable tag: 1.0.1
     7Stable tag: 1.0.2
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    123123
    124124== Changelog ==
     125= 1.0.2 =
     126* アイキャッチ画像の変換に対応
     127* 「端末に応じた画像サイズに自動変換」が有効な際、ユーザーエージェントに応じて画像サイズの設定が可能
     128* 「端末に応じた画像サイズに自動変換」が有効な際、Retinaディスプレイでは設定の2倍の画像サイズで配信する
    125129= 1.0.1 =
    126130* 表示テキストの修正
     
    129133= 0.9.0 =
    130134* テストリリース
    131 
  • imageflux/trunk/templates/diff-settings.php

    r2643143 r2712664  
    4949        </p>
    5050        <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>
    5159            <label for="quality">クオリティ指定:</label>
    5260            <input type="number" id="quality" name="quality"
Note: See TracChangeset for help on using the changeset viewer.