craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.21k stars 616 forks source link

Asset thumbs not loading on 3.0.3 upgrade #2763

Closed bphippen closed 6 years ago

bphippen commented 6 years ago

Description

Upgraded to Craft 3.0.3 and all thumbs in all asset/image fields give a 404 error. The image still exists locally and clicking through to edit the image will load the original image.

Also if "Update Asset Indexes" is clicked, it will remove all assets from the site.

I've tried this with two different locally hosted websites and both gave the same error.

Steps to reproduce

  1. Update to 3.0.3
  2. Visit Assets and thumbs will not load and give a 404.

Additional info

brandonkelly commented 6 years ago

Have you set custom values on either of your resourceBaseUrl or resourceBasePath config settings?

bphippen commented 6 years ago

All I'm using is an asset volume called Images:

screen shot 2018-04-17 at 3 36 16 pm
brandonkelly commented 6 years ago

OK, but have you set those config settings in config/general.php ?

Also if "Update Asset Indexes" is clicked, it will remove all assets from the site.

That seems to indicate that as far as Craft can tell, the asset files don’t exist. Have you made any other changes recently?

bphippen commented 6 years ago

Oh sorry no, I had to check what resourceBasePath and resourceBaseUrl settings were, and no I am not settings those in the my config file.

I am not setting asset paths in the config.

Yes, here is what happens when I click that:

screen shot 2018-04-17 at 3 48 00 pm

All of my images are in that folder locally though...

Edit* I've made no other changes recently either.

brandonkelly commented 6 years ago

Let’s look at the first file as an example (ltw-hero-girl.jpg). Which of these paths are the correct location for the file on your server?

Craft is saying that the file is indexed at the former location (volume base path + Images/…), but I’m guessing that in reality the file lives at the 2nd location (no double images/Images/).

So it looks like maybe the volume started out with a File System Path of @webroot/assets (no /images subfolder), and so it’s treating Images/ as a subfolder of the volume. Whereas now your volume’s File System Path is set to that images/ subfolder, messing up all of the existing indexes.

Is that right?

bphippen commented 6 years ago

Yes that is right, the actual location is: /assets/images/landing-pages/ltw-hero-girl.jpg

Ok, I think I can debug at this point, thanks for all your help!

There were a couple others that had the same issue, so I'm guessing with this 3.0.3 update that "bug" that was working before is now not and so the indexes are broken like you said. Since this is the first update where this issue started.

Thanks again Brandon, for your time!

brandonkelly commented 6 years ago

If you could, please point others you’ve run into with the same issue over to here. There very well could be a bug introduced by 3.0.3, and getting others onto the same thread could help us identify it.

tpmatthes commented 6 years ago

I’ve run into the same issue with a similar asset volume setup:

asset volume setup

Craft uploads images to the right directory and inserts the correct link into templates: {{ entry.myAssetsField.one.url }}. Previewing and editing files works fine, too.

However, Craft can’t generate thumbnails (CP and frontend). If I click on “Update Asset Indexes”, I get the same error message like above:

Missing files
The following files could not be found. Should they be deleted from the index?
- Bilder/Test.jpg
- ...

I don’t overwrite any volume settings with configuration files. The error also occurs, if I use @web in the “Base URL” setting and an absolute path as the “File System Path”.

What is the correct way to set up asset volumes in Craft 3? I will be happy to provide you with more information, if needed.

eheiser commented 6 years ago

Having a similar issue with a similar setup. FYI

brandonkelly commented 6 years ago

@bphippen @tpmatthes @eheiser If any of you can send admin & FTP credentials over to support@craftcms.com, that would be helpful.

eheiser commented 6 years ago

Can't help you there Brandon, this is on a local install on Mamp/OSX.

brandonkelly commented 6 years ago

Actually, we just realized we may have fixed this unintentionally by fixing another seemingly-unrelated bug.

@bphippen @tpmatthes @eheiser to test the fix, open composer.json and change the craftcms/cms version requirement to "dev-develop as 3.0.99", and then run composer update from your terminal. Once it’s done, check if asset indexing works for you again.

We aren’t able to reproduce thumbnail issues, but maybe that will sort itself out too – let us know!

eheiser commented 6 years ago

Andris came through with a fix for me so all set to continue here. Cheers!

brandonkelly commented 6 years ago

We just released 3.0.3.1 with the indexing fix. Let me know if anyone is still having issues after that!

tpmatthes commented 6 years ago

As always, thanks for the fast response, @brandonkelly

Unfortunately, it seems like the problems isn’t fully solved yet. I’ve updated Craft to 3.0.3.1, cleared the cache, updated the asset indexes and restarted MAMP. Now, I can still upload, edit and preview files, but Craft does not generate any thumbnails in the CP.

I can reproduce this bug with a new Craft installation on my local server. Please let me know, if you need additional information.

Steps to reproduce

  1. Create a fresh Craft 3.0.3.1 installation with composer
  2. Add an asset volume:
    • Name: Test
    • Handle: test
    • Assets in this volume have public URLs: sure
    • Base URL: @web/uploads/
    • File System Path: uploads/
  3. Upload an image to the asset volume

Side note: If I use @webroot/uploads/ as “File System Path”, I get this error:

HTTP 400 – Bad Request – yii\web\BadRequestHttpException
Unable to verify your data submission.

Additional info

brandonkelly commented 6 years ago

@tpmatthes Check your browser’s Network panel. What is the requested URL for a thumbnail? What is its response code?

tpmatthes commented 6 years ago

I get a 404 and a url like this: http://localhost:8888/craft3-test/web/cpresources/e97cc25a/thumb-30x30.jpg?v=1524064577

This folder doesn’t exist.

bphippen commented 6 years ago

@tpmatthes @brandonkelly I've updated to 3.0.3.1 and confirm that indexing is fixed, however I still can't see asset thumbs either.

/cpresources/397ff07d/thumb-60x60.jpg?v=1524011395

brandonkelly commented 6 years ago

@bphippen @tpmatthes Can we get admin/FTP access, or if this is local, can we set up an ip call so we can screen share and try to see what’s going on? If yes to either, please email us at support@craftcms.com

bphippen commented 6 years ago

@brandonkelly @tpmatthes so I just figured it out...

I am using Local by Flywheel as my local hosting environment, which works great for Craft projects...until for whatever reason 3.0.3

My craft projects were running fine there with Nginx as the server until 3.0.3

So I created a new craft install with nginx as the server, and the same error occurred (no thumbs). Then I switched to Apache and it works fine...

So I'll still do some testing to see why Nginx isn't working as my local server anymore.

jeffaglenn commented 6 years ago

I seem to still be having the issue as well. Fresh install of Craft 3.0.3.1 with no plugins running Apache on MAMP. Like above I can upload, edit, and preview the files they just aren't showing as thumbnails in the CP.

brandonkelly commented 6 years ago

@bphippen Check the Nginx config. Is it not forwarding requests with an extension (e.g. .jpg) to index.php ? If so that is likely the problem – Craft 3.0.3 introduced on-demand resource generation, which assumes that 404-ing resource requests will get passed to index.php. Maybe that’s not always the case.

bphippen commented 6 years ago

@brandonkelly yes that was absolutely the issue. Local by Flywheel adds this to the nginx config:

location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { access_log off; log_not_found off; expires max; }

That line was the culprit, commented that out and thumbs are now loading.

Thanks again for all your help!

brandonkelly commented 6 years ago

@bphippen Cool, we’ll go back to eager-publishing CP resource files to work around that in 3.0.4.

tpmatthes commented 6 years ago

@brandonkelly At the moment, I can’t share my screen with this setup. However, if this can’t be fixed until next week, I’ll do some additional testing and try to create a demo server. In the meantime, I am happy to provide you with some screenshots or log files. Would this be helpful?

Some additional information:

brandonkelly commented 6 years ago

@tpmatthes Can you post a screen shot of that error?

jeffaglenn commented 6 years ago

@brandonkelly Here is a screenshot of the error I'm getting. I would imagine it's the same as @tpmatthes.

screen shot 2018-04-19 at 7 58 22 pm
tpmatthes commented 6 years ago

@jeffaglenn Yes, that’s exactly the same error, thanks

brandonkelly commented 6 years ago

@jeffaglenn Just tested with MAMP, with a Local volume with Base URL and File System Path settings using the @web and @webroot aliases, and thumbs continue to work, even after clearing my Asset Caches and Control Panel Resources.

Anyway, it shouldn’t be an issue anymore with the next release, as we’ve gone back to eager-publishing these resources like we did before 3.0.3.

buro-buro commented 5 years ago

I have same problem and we solved it by deleting the folders and generating them directly from craft. This way craft automatically puts the permissions of 755. If you want to solve it you can just change the permits to 755 of the folder permissions.

alipetarian commented 2 years ago

try like this

<img src="https://dev-craft3-384fa3039dfb.hyperlane.co/uploads/scren1.png" referrerpolicy="no-referrer" alt="ALI TEST LIVE LINK" />