Plugin Directory

Changeset 2313195


Ignore:
Timestamp:
05/27/2020 02:19:01 PM (6 years ago)
Author:
image4io
Message:

Update to Version 0.3.1

Location:
image4io
Files:
5 edited
33 copied

Legend:

Unmodified
Added
Removed
  • image4io/tags/0.3.1/image4io.php

    r2292451 r2313195  
    88Description: Speeds up the images' load time: image optimization, image CDN and image storage, all-in-one platform. To get started: activate the image4io plugin and then go to your Image4io Settings page to set up your credentials.
    99Author: image4io
    10 Version: 0.3.0
     10Version: 0.3.1
    1111Author URI: https://image4.io
    1212*/
  • image4io/tags/0.3.1/inc/Manager/MediaManager.php

    r2292451 r2313195  
    3737        add_action('admin_footer-upload.php', array($this, 'image4io_media_lib_upload_admin_footer'));
    3838        add_action('load-upload.php', array($this, 'image4io_media_lib_upload_action'));
     39        //add_action('delete_attachment',array($this,'image4io_media_delete'),1,1);
    3940        add_filter('wp_generate_attachment_metadata',array($this,'image4io_upload_new_media_action'),1,3);
    4041        add_filter('wp_get_attachment_url', array($this, 'fix_local_url_to_image4io'), 1, 2);
     
    373374            return 'Unsupported attachment type!';
    374375        }
     376        $full_path = $this->update_urls_for_ssl($full_path);
    375377
    376378        $manager = new Image4IOManager;
     
    635637    }
    636638
    637     public function image4io_generate_image_srcset($image_src, $image_meta, $attachment_id){
    638         /*if (!isset($image_meta['image4io']) || !$image_meta['image4io']){
    639             return $sources;
    640         }*/
    641         $sizes=$image_meta['image4io_sizes'];
    642        
    643         $results=array();
    644         foreach($sizes as $size){
    645             $result=array(
    646                 'url'=>$size['file'],
    647                 'descriptor'=>'w',
    648                 'value'=>$size['width'],
    649             );
    650             $results[$size['width']]=$result;
    651         }
    652         //unset($size);
    653        
    654         if ( ! is_array( $results ) || count( $results ) < 1 ) {
    655             return false;
    656         }
    657 
    658         $srcset = '';
    659        
    660         foreach ( $results as $result ) {
    661             $srcset .= str_replace( ' ', '%20', $result['url'] ) . ' ' . $result['value'] . $result['descriptor'] . ', ';
    662         }
    663         $srcset = rtrim($srcset, ', ');
    664         $srcset_sizes= wp_calculate_image_sizes( array($image_meta["width"],$image_meta["height"]), $image_src, $image_meta, $attachment_id );
    665        
    666         preg_match('/(^.*?src=\"[^"]+")(.*)/i',$image_src,$res);
    667        
    668         return $res[1] . ' srcset="' . $srcset . '" sizes="' . $srcset_sizes . '"' . $res[2];
    669     }
    670 
    671639    public function image4io_make_content_responsive($content){
     640       
    672641        if ( ! preg_match_all( '/<img [^>]+>/', $content, $matches ) ) {
    673642            return $content;
     
    691660            }
    692661        }
     662       
    693663        if ( count( $attachment_ids ) > 1 ) {
    694664            /*
     
    698668            _prime_post_caches( array_keys( $attachment_ids ), false, true );
    699669        }
    700        
    701670        foreach ( $selected_images as $image => $attachment_id ) {
    702671            $image_meta = wp_get_attachment_metadata( $attachment_id );
    703             $content    = str_replace( $image, $this->image4io_generate_image_srcset( $image, $image_meta, $attachment_id ), $content );
     672            $updatedSrc=$this->image4io_generate_image_srcset( $image, $image_meta, $attachment_id );
     673            $content    = str_replace( $image, $updatedSrc , $content );
    704674        }
    705675   
    706676        return $content;
     677    }
     678   
     679    public function image4io_generate_image_srcset($image_src, $image_meta, $attachment_id){
     680        $sizes=$image_meta['image4io_sizes'];
     681       
     682        if(! is_array( $sizes ) || count( $sizes ) < 1){
     683            return $image_src;
     684        }
     685        $results=array();
     686       
     687        foreach($sizes as $size){
     688            $result=array(
     689                'url'=>$size['file'],
     690                'descriptor'=>'w',
     691                'value'=>$size['width'],
     692            );
     693            $results[$size['width']]=$result;
     694        }
     695
     696        $srcset = '';
     697       
     698        foreach ( $results as $result ) {
     699            $srcset .= str_replace( ' ', '%20', $result['url'] ) . ' ' . $result['value'] . $result['descriptor'] . ', ';
     700        }
     701        $srcset = rtrim($srcset, ', ');
     702        $srcset_sizes= wp_calculate_image_sizes( array($image_meta["width"],$image_meta["height"]), $image_src, $image_meta, $attachment_id );
     703       
     704        preg_match('/(^.*?src=\"[^"]+")(.*)/i',$image_src,$res);
     705
     706        return $res[1] . ' srcset="' . $srcset . '" sizes="' . $srcset_sizes . '"' . $res[2];
    707707    }
    708708
     
    746746            }
    747747
     748            $full_path = $this->update_urls_for_ssl($full_path);
     749
    748750            $manager = new Image4IOManager;
    749751            $manager->setup();
     
    766768        }
    767769    }
     770
     771    /*public function image4io_media_delete($postid){
     772        $md = wp_get_attachment_metadata($attachment_id);
     773        if(isset($md['image4io'])&&$md['image4io']){
     774            $manager = new Image4IOManager;
     775            $manager->setup();
     776            $result = $manager->uploadToImage4ioFromUrl($full_path,"/");
     777            var_dump($result);
     778            die;
     779        }
     780    }*/
     781
     782    public function update_urls_for_ssl($url) {
     783        //Correct protocol for https connections
     784        list($protocol, $uri) = explode('://', $url, 2);
     785        if(is_ssl()) {
     786            if('http' == $protocol) {
     787            $protocol = 'https';
     788            }
     789        } else {
     790            if('https' == $protocol) {
     791            $protocol = 'http';
     792            }
     793        }
     794       
     795        return $protocol.'://'.$uri;
     796    }
    768797 }
  • image4io/tags/0.3.1/package-lock.json

    r2292451 r2313195  
    11{
    22  "name": "image4io",
    3   "version": "0.2.0",
     3  "version": "0.3.1",
    44  "lockfileVersion": 1,
    55  "requires": true,
  • image4io/tags/0.3.1/package.json

    r2292451 r2313195  
    11{
    22  "name": "image4io",
    3   "version": "0.2.0",
     3  "version": "0.3.1",
    44  "description": "image4io Wordpress Plugin. Speeds up the images' load time: image optimization, image CDN and image storage, all-in-one platform.",
    55  "main": "index.js",
  • image4io/tags/0.3.1/readme.txt

    r2292451 r2313195  
    118118* Fixed a bug when uploading images to image4io server.
    119119
     120= 0.3.1 =
     121* Fixed a bug when hosting server activated ssl.
     122
    120123== UPGRADE NOTICE ==
    121124
  • image4io/trunk/image4io.php

    r2292451 r2313195  
    88Description: Speeds up the images' load time: image optimization, image CDN and image storage, all-in-one platform. To get started: activate the image4io plugin and then go to your Image4io Settings page to set up your credentials.
    99Author: image4io
    10 Version: 0.3.0
     10Version: 0.3.1
    1111Author URI: https://image4.io
    1212*/
  • image4io/trunk/inc/Manager/MediaManager.php

    r2292451 r2313195  
    3737        add_action('admin_footer-upload.php', array($this, 'image4io_media_lib_upload_admin_footer'));
    3838        add_action('load-upload.php', array($this, 'image4io_media_lib_upload_action'));
     39        //add_action('delete_attachment',array($this,'image4io_media_delete'),1,1);
    3940        add_filter('wp_generate_attachment_metadata',array($this,'image4io_upload_new_media_action'),1,3);
    4041        add_filter('wp_get_attachment_url', array($this, 'fix_local_url_to_image4io'), 1, 2);
     
    373374            return 'Unsupported attachment type!';
    374375        }
     376        $full_path = $this->update_urls_for_ssl($full_path);
    375377
    376378        $manager = new Image4IOManager;
     
    635637    }
    636638
    637     public function image4io_generate_image_srcset($image_src, $image_meta, $attachment_id){
    638         /*if (!isset($image_meta['image4io']) || !$image_meta['image4io']){
    639             return $sources;
    640         }*/
    641         $sizes=$image_meta['image4io_sizes'];
    642        
    643         $results=array();
    644         foreach($sizes as $size){
    645             $result=array(
    646                 'url'=>$size['file'],
    647                 'descriptor'=>'w',
    648                 'value'=>$size['width'],
    649             );
    650             $results[$size['width']]=$result;
    651         }
    652         //unset($size);
    653        
    654         if ( ! is_array( $results ) || count( $results ) < 1 ) {
    655             return false;
    656         }
    657 
    658         $srcset = '';
    659        
    660         foreach ( $results as $result ) {
    661             $srcset .= str_replace( ' ', '%20', $result['url'] ) . ' ' . $result['value'] . $result['descriptor'] . ', ';
    662         }
    663         $srcset = rtrim($srcset, ', ');
    664         $srcset_sizes= wp_calculate_image_sizes( array($image_meta["width"],$image_meta["height"]), $image_src, $image_meta, $attachment_id );
    665        
    666         preg_match('/(^.*?src=\"[^"]+")(.*)/i',$image_src,$res);
    667        
    668         return $res[1] . ' srcset="' . $srcset . '" sizes="' . $srcset_sizes . '"' . $res[2];
    669     }
    670 
    671639    public function image4io_make_content_responsive($content){
     640       
    672641        if ( ! preg_match_all( '/<img [^>]+>/', $content, $matches ) ) {
    673642            return $content;
     
    691660            }
    692661        }
     662       
    693663        if ( count( $attachment_ids ) > 1 ) {
    694664            /*
     
    698668            _prime_post_caches( array_keys( $attachment_ids ), false, true );
    699669        }
    700        
    701670        foreach ( $selected_images as $image => $attachment_id ) {
    702671            $image_meta = wp_get_attachment_metadata( $attachment_id );
    703             $content    = str_replace( $image, $this->image4io_generate_image_srcset( $image, $image_meta, $attachment_id ), $content );
     672            $updatedSrc=$this->image4io_generate_image_srcset( $image, $image_meta, $attachment_id );
     673            $content    = str_replace( $image, $updatedSrc , $content );
    704674        }
    705675   
    706676        return $content;
     677    }
     678   
     679    public function image4io_generate_image_srcset($image_src, $image_meta, $attachment_id){
     680        $sizes=$image_meta['image4io_sizes'];
     681       
     682        if(! is_array( $sizes ) || count( $sizes ) < 1){
     683            return $image_src;
     684        }
     685        $results=array();
     686       
     687        foreach($sizes as $size){
     688            $result=array(
     689                'url'=>$size['file'],
     690                'descriptor'=>'w',
     691                'value'=>$size['width'],
     692            );
     693            $results[$size['width']]=$result;
     694        }
     695
     696        $srcset = '';
     697       
     698        foreach ( $results as $result ) {
     699            $srcset .= str_replace( ' ', '%20', $result['url'] ) . ' ' . $result['value'] . $result['descriptor'] . ', ';
     700        }
     701        $srcset = rtrim($srcset, ', ');
     702        $srcset_sizes= wp_calculate_image_sizes( array($image_meta["width"],$image_meta["height"]), $image_src, $image_meta, $attachment_id );
     703       
     704        preg_match('/(^.*?src=\"[^"]+")(.*)/i',$image_src,$res);
     705
     706        return $res[1] . ' srcset="' . $srcset . '" sizes="' . $srcset_sizes . '"' . $res[2];
    707707    }
    708708
     
    746746            }
    747747
     748            $full_path = $this->update_urls_for_ssl($full_path);
     749
    748750            $manager = new Image4IOManager;
    749751            $manager->setup();
     
    766768        }
    767769    }
     770
     771    /*public function image4io_media_delete($postid){
     772        $md = wp_get_attachment_metadata($attachment_id);
     773        if(isset($md['image4io'])&&$md['image4io']){
     774            $manager = new Image4IOManager;
     775            $manager->setup();
     776            $result = $manager->uploadToImage4ioFromUrl($full_path,"/");
     777            var_dump($result);
     778            die;
     779        }
     780    }*/
     781
     782    public function update_urls_for_ssl($url) {
     783        //Correct protocol for https connections
     784        list($protocol, $uri) = explode('://', $url, 2);
     785        if(is_ssl()) {
     786            if('http' == $protocol) {
     787            $protocol = 'https';
     788            }
     789        } else {
     790            if('https' == $protocol) {
     791            $protocol = 'http';
     792            }
     793        }
     794       
     795        return $protocol.'://'.$uri;
     796    }
    768797 }
  • image4io/trunk/package-lock.json

    r2292451 r2313195  
    11{
    22  "name": "image4io",
    3   "version": "0.2.0",
     3  "version": "0.3.1",
    44  "lockfileVersion": 1,
    55  "requires": true,
  • image4io/trunk/package.json

    r2292451 r2313195  
    11{
    22  "name": "image4io",
    3   "version": "0.2.0",
     3  "version": "0.3.1",
    44  "description": "image4io Wordpress Plugin. Speeds up the images' load time: image optimization, image CDN and image storage, all-in-one platform.",
    55  "main": "index.js",
  • image4io/trunk/readme.txt

    r2292451 r2313195  
    118118* Fixed a bug when uploading images to image4io server.
    119119
     120= 0.3.1 =
     121* Fixed a bug when hosting server activated ssl.
     122
    120123== UPGRADE NOTICE ==
    121124
Note: See TracChangeset for help on using the changeset viewer.