WordPress.org

Ready to get started?Download WordPress

Forums

Dynamic Image Resizer
Bug Report - Workaround (1 post)

  1. brent113
    Member
    Posted 1 year ago #

    Using plugin version 1.0 with WordPress 3.5.2 was serving up corrupted images - I traced it to WordPress having erroneous things in the output buffer. Also the plugin didn't change the status code to 200 (instead it was left at 404, not really a critical problem though).

    Solution was to change the end of the dynimg_404_handler() function to look like this:

    // serve the image this one time (next time the webserver will do it for us)
    	header_remove();
    
    	flush();
    	ob_end_clean();
    
    	status_header( '200' );
    	header( 'Content-Type: '.$type );
    	header( 'Content-Length: ' . filesize($resized) );
    
    	readfile($resized);
    
    	exit;

    Also, WordPress now has the image_resize function listed as deprecated, so I updated that section as well:

    if ( file_exists($basefile) ) {
    	// we have the file, so call the wp function to actually resize the image
    	//OLD function $resized = image_resize($basefile, $width, $height, $crop, $suffix);
    
    	$editor = wp_get_image_editor( $basefile );
    	$editor->set_quality( 90 );
    
    	$resized = $editor->resize( $width, $height, $crop );
    	if ( is_wp_error( $resized ) )
    		return $resized;
    
    	$dest_file = $editor->generate_filename( $suffix, null );
    	$editor->save( $dest_file );
    	$resized = $dest_file;

    http://wordpress.org/extend/plugins/dynamic-image-resizer/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.