Dynamic Image Resizer
[resolved] Images with special characters are not resized (2 posts)

  1. MilaWitjes
    Posted 4 years ago #


    Great plugin! It saved me a lot of MB's!

    There are two things that may be improved:
    1) Images with special characters in their filenames are not resized because the url is not decoded first. I found that changing line 19 from
    $filename = $matches[1].'.'.$matches[5];
    $filename = urldecode($matches[1].'.'.$matches[5]);
    fixed that problem.

    2) The plugin uses the character 'c' at the end of a filename to indicate it needs to be cropped. This didn't work for the images I had already uploaded before I installed the plugin. Maybe you can think of a solution for this. I fixed it by deleting all the resized images WordPress had created before. Then I changed the filenames in the metadata by running the following script:

    $args = array(
        'numberposts'     => -1,
        'offset'          => 0,
        'category'        => NULL,
        'orderby'         => 'post_date',
        'order'           => 'DESC',
        'include'         => NULL,
        'exclude'         => NULL,
        'meta_key'        => NULL,
        'meta_value'      => NULL,
        'post_type'       => 'attachment',
        'post_mime_type'  => NULL,
        'post_parent'     => NULL,
        'post_status'     => NULL );
    $attachments = get_posts( $args );
    foreach ($attachments as $attachment) {
    	$meta = (get_post_meta( $attachment->ID ,'_wp_attachment_metadata'));
    	$meta_new = $meta;
    	$sizes = $meta[0]['sizes'];
    	if ($sizes) foreach ($sizes as $size=>$value) {
    		if (in_array($size,array('thumbnail', 'post-thumbnail', 'featured-image'))) { // put your images that need to be cropped here
    			$filename = $value['file'];
    			if (!preg_match('/(.*)(c).(jpg|png|gif)/i',$filename) ) {
    		   		if (preg_match('/(.*).(jpg|png|gif)/i',$filename,$matches) ) {
    					$newfilename = $matches[1].'c.'.$matches[2];
    					echo 'Found: '.$newfilename."\r";
    					$meta_new[0]['sizes'][$size]['file'] = $newfilename;

    Best regards,
    Mila Witjes


  2. Tropa
    Posted 4 years ago #

    Thanks for your tips :)

    You know how to change the code to when resize images made proportionally and fill all the resize image?

    Because when I upload a photo and when resize for a size of theme the cropped image appear with black bar on the right size.

    If I disable plugin the cropped image by the WordPress appears correctly.

    Thank you.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Dynamic Image Resizer
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic