WordPress.org

Plugin Directory

Changeset 625342


Ignore:
Timestamp:
11/14/12 20:12:38 (17 months ago)
Author:
dllh
Message:

Posterous Importer: Use filters for saving the url remapping in a couple of places I missed in a previous commit. Also add support for download and remapping of PDFs and a couple of Microsoft formats that it's plausible people might have uploaded.

File:
1 edited

Legend:

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

    r623129 r625342  
    514514 
    515515            printf( "<em>%s</em>", __( 'Checking' ) . " '$post->post_title' " . __( 'for media...' ) ); 
    516             $attachments = $this->extract_post_media( $media ); 
     516            $attachments = $this->extract_post_media( $media, $post ); 
    517517            printf( "<em>%s</em><br />\n", ' ' . sizeof( $attachments ) . ' ' . __( 'media files found' ) ); 
    518518 
     
    556556 
    557557            // Update url_remap array 
    558             $this->url_remap[ $attachment->url ] = $attachment_url; 
     558            do_action( 'posterous_store_url_remap', $post->ID, $attachment->url, $attachment_url ); 
    559559            $sized = image_downsize( $post_id, 'medium' ); 
    560560            foreach ( $attachment->thumbs as $thumb ) { 
     
    616616        $attachment_url = wp_get_attachment_url( $post_id ); 
    617617        // Update url_remap array 
    618         $this->url_remap[ $attachment->url ] = $attachment_url; 
     618        do_action( 'posterous_store_url_remap', $post->ID, $attachment->url, $attachment_url ); 
    619619        $sized = image_downsize( $post_id, 'medium' ); 
    620620        if ( isset( $attachment->thumbs ) ) { 
     
    720720     * @return array 
    721721     */ 
    722     function extract_post_media( $media ) { 
     722    function extract_post_media( $media, $post ) { 
    723723        $attachments = array(); 
    724724        foreach ( $media as $file ) { 
     
    737737            } 
    738738             
     739        } 
     740        preg_match_all( '!href=(\'|")(http:\/\/[a-zA-Z0-9\-+%\&\?#\/\.]+\/files\.posterous\.com\/[a-zA-Z0-9\-+%_&\?#\/\.]+\.(doc|xls|pdf|docx))(\'|")!i', $post->post_content, $matches ); 
     741        foreach ( $matches[2] as $file ) { 
     742            $obj = new stdClass(); 
     743            $obj->url = $file; 
     744            $attachments[] = $obj; 
    739745        } 
    740746        return $attachments; 
Note: See TracChangeset for help on using the changeset viewer.