WordPress.org

Plugin Directory

Changeset 621398


Ignore:
Timestamp:
11/05/12 20:08:35 (18 months ago)
Author:
dllh
Message:

Posterous Importer: The Posterous API gives us the urls used in posts (scaled) rather than original image urls, which causes us to download scaled down versions of the files. Add some bits to prevent that.

Location:
posterous-importer/branches/v2api
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • posterous-importer/branches/v2api/posterous.php

    r620761 r621398  
    736736            if ( strstr( $url, 'posterous.com' ) ) { 
    737737                $attachments['thumb'][$i] = $matches[2][$i]; 
    738                 $attachments['fullsize'][$i] = $url; 
     738                $attachments['fullsize'][$i] = $this->remove_scaling_from_image_url( $url ); 
    739739            } 
    740740        } 
     
    744744        preg_match_all( '|<img.*?src=[\'"](.*?)[\'"].*?>|i', $post_content, $matches ); 
    745745        foreach ( $matches[1] as $i => $url ) { 
     746            $url = $this->remove_scaling_from_image_url( $url ); 
    746747            if ( strstr( $url, 'posterous.com' ) && !in_array( $url, $attachments['thumb'] ) && !in_array( $url, $attachments['fullsize'] ) ) { 
    747748                $attachments['single'][$i] = $url; 
     
    785786 
    786787        return $hashtable; 
     788    } 
     789 
     790    function remove_scaling_from_image_url( $url ) { 
     791        $new_url = preg_replace( '!\.scaled\d+\.(jpg|jpeg|gif|png)$!i', '', $url ); 
     792        $new_url = preg_replace( '!getfile\d+\.posterous.com!', 'getfile.posterous.com', $new_url ); 
     793        $this->url_remap[ $url ] = $new_url; 
     794        return $new_url; 
    787795    } 
    788796 
  • posterous-importer/branches/v2api/readme.txt

    r620761 r621398  
    2323= 0.11 - 3rd Nov 2012 
    2424* Better handling of UTF-8 in responses from the API. 
     25* Add a function to remove filename infixes from image urls that cause small versions of larger images to be downloaded. 
    2526 
    2627= 0.10 - 26th Mar 2012 
Note: See TracChangeset for help on using the changeset viewer.