I'm using Media Entity and Image Bundle, but the upload through the media/add/image_bundle form is not working correctly. After uploading an image it can't be shown on the created node (media/xy). There is just the alt text linked to the original file (if configured in manage display). And in the media list (admin/content/media) the thumbnails are not visible.

UPDATE:
Apparently this is not only a problem with Media Entity but also with normal image fields - when Image Styles are activated (orignal image shows well). So File (Field) Paths correctly puts a file in the intended folder:
Original File: sites/default/files/newsimage/2016/image.jpg

But the path and the file given in the img src doesn't exist:
Image Style File: sites/default/files/styles/large/public/newsimage/2016/image.jpg

UPDATE 2:
So I encountered the same problem in a new project. But this time I noticed that the image style files are created after uploading if one image style is selected in the display options of the content type. If no image style is selected but original image then no image styles are created. So after changing the image style in the display options the image disappears.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

johnnny83 created an issue. See original summary.

johnnny83’s picture

Issue summary: View changes
johnnny83’s picture

Issue summary: View changes
johnnny83’s picture

Title: Media upload not working correctly with Media Entity/Image bundle » After image upload no images styles are created
Issue summary: View changes
rooby’s picture

This seems to also happen if you use the retro update.

After the update all the files that were changed do not generate styles anymore.

rooby’s picture

Priority: Normal » Major
Anonymous’s picture

For some reason, this module forces uploads to go through the temporary file system in a hook_field_widget_form_alter(). When it does, urls for the image preview are not recognised as image style urls and instead are handled as file downloads, thus resulting in 404.

Not sure if this is the issue OP is referring to, but I found this out using the same modules.

kiwi_steve’s picture

I'm having the same problem. With a customised file location:

images/[node:field_brand]/[node:title]

I'm finding that the related image style location becomes:

/sites/default/files/styles/thumbnail/public/filefield_paths

I believe this is related to /sites/default/files/filefield_paths being the folder where images go when they are first uploaded in the edit node page. When saved, they shift to the new (correct) location, however the styles do not.

Could this be due to the edit page creating and displaying the thumbnail as part of the image upload preview? because if you go back into edit the node the thumbnails are now absent. Is this confusing the styles file locations?

I'd love a solution to this, as this functionality is fairly critical to me. I'll have a look at the module myself, but my PHP skills are years out of date (like my Drupal skills) and somewhat rusty.

Cheers

Steve

kiwi_steve’s picture

UPDATE:

In my case, I believe I may have found the source of this problem - I'm developing on Windows :)

I haven't yet moved it to my Linux server to see if the issues resolves itself in that environment, but the file names of uploaded images are being stored in the file_managed table of the database like this:
public://images/ultimate/cpu\ultimate_cpu_543377476.jpg

...one of these slashes is not like the other, one of these slashes is not quite the same...

If I manually manipulate the database and reverse the last (windows style) slash just before the filename, clear the Drupal cache, and then fully refresh the page (CTRL-F5) - the image styles are created and the image will show up.

Is this just an OS-specific PHP file/path join operation going wrong? If so, as a fix for my own site I can manually manipulate these for the images I'm using in development and then just add the bulk of the data once the site is on the server (assuming it is an OS-specific fault - I'll test that when I have time). NOTE: I've now ported the site to my Linux webserver and the problem has solved itself... so it seems as if this is indeed a dodgy join operation, using a windows join between the path and the filename when it probably shouldn't be

It seems like this problem might be easy enough to correct.... if I knew where to look.... which I don't :/

Cheers

Steve

rooby’s picture

@kiwi_steve:

There is another issue for the Windows slashes: #2858308: File paths are written to the DB with back slashes on Windows servers
Could be related but I think they are separate issue.

[EDIT] actually now I'm second guessing myself, but I'm pretty sure I've seen this issue on ubuntu.

johnnny83’s picture

Issue summary: View changes
jjancel’s picture

I have the same problem with microsoft servers, while everything works well under linux

bohus ulrych’s picture

Hi,
if you are facing with thumbnails generating on Windows then really check #2858308: File paths are written to the DB with back slashes on Windows servers

P.S. This ticket title (...no images styles are created) is more corresponding to the real issue than #2858308 title.

johnnny83’s picture

I'm still having this issue on Linux, so I can't use File (Field) Paths

jay.lee.bio’s picture

For me, this issue only happened for the first image. But #6 in issue #2858308 took care of it.

mehrdad201’s picture

I have the same problems

image styles are not created when I use file field path in my Drupal 8.
I have tested both filefield_paths-8.x-1.0-beta5.tar.gz and filefield_paths-8.x-1.x-dev.tar.gz versions.

Even though beta5 is released on December 1, 2020 (7 days ago), the problem still exists.

I found no patch to get rid of this problem.

voleger made their first commit to this issue’s fork.

voleger’s picture

Status: Active » Fixed

Introduced test \Drupal\Tests\filefield_paths\Functional\FileFieldPathsGeneralTest::testImageStyleDerivativeGeneration which checks the Image style URL and file presence in the filesystem by URI.
Feel free to reopen as a new issue, and describe the steps to reproduce if the problem persists.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • voleger committed a56d61ea on 8.x-1.x
    feat: #2827652 After image upload no images styles are created
    
    By:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.