Plugin Directory

Changeset 1496066


Ignore:
Timestamp:
09/15/2016 02:06:33 AM (9 years ago)
Author:
yamamotofebc
Message:

0.0.7

Location:
wp-sacloud-ojs/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-sacloud-ojs/trunk/readme.txt

    r1495668 r1496066  
    55Requires at least: 4.5.3
    66Tested up to: 4.6.1
    7 Stable tag: 0.0.6
     7Stable tag: 0.0.7
    88License: GPLv2 or later.
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5050== Changelog ==
    5151
    52 0.0.6 : アップロード先の年月ディレクトリ対応、キャッシュ配信関連バグ修正、移行手順追加
     520.0.7 : [srcset属性のURL書き換え対応](https://github.com/yamamoto-febc/wp-sacloud-ojs/releases/tag/v0.0.7)
    5353
    54 0.0.5 : WP-CLI対応、オプション値の内部構造変更、アップロード後のファイル削除オプション対応
     540.0.6 : [アップロード先の年月ディレクトリ対応、キャッシュ配信関連バグ修正、移行手順追加](https://github.com/yamamoto-febc/wp-sacloud-ojs/releases/tag/v0.0.6)
    5555
    56 0.0.4 : メディアファイル削除時のフィルタロジック修正
     560.0.5 : [WP-CLI対応、オプション値の内部構造変更、アップロード後のファイル削除オプション対応](https://github.com/yamamoto-febc/wp-sacloud-ojs/releases/tag/v0.0.5)
    5757
    58 0.0.3 : メディアファイル削除時にuploadsディレクトリ内にファイルが残存するバグを修正
     580.0.4 : [メディアファイル削除時のフィルタロジック修正](https://github.com/yamamoto-febc/wp-sacloud-ojs/releases/tag/v0.0.4)
    5959
    60 0.0.2 : 再同期時にサムネイルを生成する機能追加
     600.0.3 : [メディアファイル削除時にuploadsディレクトリ内にファイルが残存するバグを修正](https://github.com/yamamoto-febc/wp-sacloud-ojs/releases/tag/v0.0.3)
     61
     620.0.2 : [再同期時にサムネイルを生成する機能追加](https://github.com/yamamoto-febc/wp-sacloud-ojs/releases/tag/v0.0.2)
    6163
    62640.0.1 : 初回リリース
  • wp-sacloud-ojs/trunk/wp-sacloud-ojs.php

    r1495668 r1496066  
    88 * Author URI: https://github.com/yamamoto-febc
    99 * Text Domain: wp-sacloud-ojs
    10  * Version: 0.0.6
     10 * Version: 0.0.7
    1111 * License: GPLv2
    1212 */
     
    4444
    4545        add_filter('wp_get_attachment_url', 'sacloudojs_object_storage_url');
    46 
     46        add_filter('wp_calculate_image_srcset', 'sacloudojs_calculate_image_srcset', 10, 5);
    4747
    4848        if (Wp_Sacloud_Ojs\Options::$Instance->DeleteObject === '1') {
     
    333333}
    334334
     335// Return object URL(srcset)
     336function sacloudojs_calculate_image_srcset($sources, $size_array, $image_src, $image_meta, $attachment_id)
     337{
     338    foreach ($sources as &$src) {
     339        $url = $src['url'];
     340
     341        $object_name = __generate_object_name_from_url($url);
     342        if ($object_name) {
     343            $url = Wp_Sacloud_Ojs\Options::$Instance->getObjectURLByName($object_name);
     344            $src['url'] = $url;
     345        }
     346    }
     347    return $sources;
     348}
     349
    335350// -------------------- internal functions --------------------
    336351
     
    352367    return $container_name . $prefix . $name;
    353368}
     369
     370function __generate_object_name_from_url($url)
     371{
     372
     373    $dir = wp_upload_dir();
     374    $name = str_replace($dir['url'] . DIRECTORY_SEPARATOR , '' , $url);
     375
     376    $prefix = str_replace($dir['baseurl'] . DIRECTORY_SEPARATOR, '', $dir['url']) . DIRECTORY_SEPARATOR;
     377
     378    $container_name = Wp_Sacloud_Ojs\Options::$Instance->Container;
     379    if ($container_name != "") {
     380        $container_name .= "/";
     381    }
     382
     383    return $container_name . $prefix . $name;
     384
     385}
     386
    354387
    355388function __get_attachment_id_from_url($url)
Note: See TracChangeset for help on using the changeset viewer.