Hi,

Thank you for a wonderful module. One issue I found is if Minify Source HTML is enabled, the image preview for an image upload fails and gives a content-length error.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

heinc8 created an issue. See original summary.

slydevil’s picture

Are you using any contrib modules to handle the image preview?

sense-design’s picture

Yes, I am using Focal Point

slydevil’s picture

I've installed the focal point module and it is working just fine for me. Can you elaborate more on what issue you are facing, steps to reproduce, etc.

sense-design’s picture

Using these modules:

* Paragraphs with simple bundle with image field
* Transliteration
* Image Field Caption
* Focal point
* ImageMagick

Server software:
* ngnix

When uploading a picture the following errors occurs in Debug console:
"/sites/default/files/styles/thumbnail/public/pictures/paragraphs/name-of-file.jpg?itok=88D3Tsr5:1
GET https://www.domain.tld/sites/default/files/styles/thumbnail/public/pictu... net::ERR_CONTENT_LENGTH_MISMATCH"

Maybe I could give you access to the DEV site to have a look at the error.

heinc8’s picture

No, I'm not using a contrib module to generate the preview. When Minify Source HTML is enabled, after you've uploaded an image, the browser shows it can't load the preview and the console delivers the ERR_CONTENT_LENGTH_MISMATCH error. When Minify Source HTML is switched off, it renders the preview correctly. It does the same in all browsers. I'm using jQuery Update and Speedy. Turning off Speedy doesn't solve the issue.

heinc8’s picture

I think it might be related to generating styles. When it shows the thumbnail, it is generating the style for the first time. It may happen too late and the size the browser expects is different to what it receives (the style image vs the original one).

slydevil’s picture

@sense-design, access to a dev site would help. I cannot reproduce this at all...it always works. It could be related to the server configuration.

slydevil’s picture

My personal contact form, cannot verify if it is actually there or not though

https://www.drupal.org/user/1846786/contact

slydevil’s picture

Status: Active » Postponed (maintainer needs more info)

Can you confirm if you have compression enabled? If so, try the latest release 7.x-1.1 which should fix the issue.

heinc8’s picture

Thanks. I'll test it and let you know.

pavloki’s picture

I have same error. When style have not yet created (first time access to style image) - there is an error in browser "content lengh". It seems like module Minify Source HTML trying to minify also images.

Ngix config look like this:

# Try to get image:
location ~* \.(pdf|asc|dat|txt|doc|xls|ppt|tgz|csv|png|gif|jpeg|jpg|ico|swf|css|js|json|svg)$ {
log_not_found off;
try_files $uri @rewrite;
expires 30d;
}

# There is no image - so do this:
location @rewrite {
rewrite ^/(.*)$ /index.php?q=$1;
}

So the final request to drupal seems like this http://site.com/index.php?q=sites/default/files/styles/large/public/imag...

And as I understood Minify Source HTML is minifing jpg image from url http://site.com/index.php?q=sites/default/files/styles/large/public/imag...
Please, fix it!

pavloki’s picture

I have same error. When style have not yet created (first time access to style image) - there is an error in browser "content lengh". It seems like module Minify Source HTML trying to minify also images.

Ngix config look like this:

# Try to get image:
location ~* \.(pdf|asc|dat|txt|doc|xls|ppt|tgz|csv|png|gif|jpeg|jpg|ico|swf|css|js|json|svg)$ {
log_not_found off;
try_files $uri @rewrite;
expires 30d;
}

# There is no image - so do this:
location @rewrite {
rewrite ^/(.*)$ /index.php?q=$1;
}

So the final request to drupal seems like this http://site.com/index.php?q=sites/default/files/styles/large/public/imag...

And as I understood Minify Source HTML is minifing jpg image from url http://site.com/index.php?q=sites/default/files/styles/large/public/imag...
Please, fix it!

7.x-1.1 have same problem, not fixed.

heinc8’s picture

@slydevil, unfortunately, it is still an issue.

I had to add the following at line 36 of minifyhtml.module to ensure that it doesn't try to process any paths with extensions.

// Do not process a path that is actually a file (it breaks style generation)
if(function_exists('current_path')) {
  $currentPath = current_path();
  if(is_file($currentPath)) {
    return;
  }
}
heinc8’s picture

Status: Postponed (maintainer needs more info) » Needs work
slydevil’s picture

Status: Needs work » Needs review
FileSize
1.92 KB

Check the attached path, see if it does the trick. It's essentially the same as the code you posted.

heinc8’s picture

@slydevil, thanks, I'll try it today.

heinc8’s picture

Status: Needs review » Reviewed & tested by the community

@slydevil. Thanks, #16 works.

  • slydevil committed d0f453c on 7.x-1.x
    Issue #2887928 by slydevil: Image Upload Preview Fails (Content-Length)
    
slydevil’s picture

Status: Reviewed & tested by the community » Fixed
slydevil’s picture

Status: Fixed » Closed (fixed)