-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image gets saved to file system, but incorrect image path is saved in media attachment #66
Comments
I was able to get around this issue by temporarily disabling the "Organize my uploads into month- and year-based folders" setting. Still keeping this issue open as the current plugin breaks with the default setting. (I'd wager this is some kind of regex weirdness going on) |
Just to help out people in the future who have the same issue: the "Organize my uploads into month-..." option is located under general WP Media settings (/wp-admin/options-media.php), not in this plugin-specific settings. |
I found a solution, replace the following code wp-auto-upload/src/ImageUploader.php Lines 256 to 260 in 1305af6
by
Because |
I couldn't test and debug this problem and I think probably it happens in Windows OS also it's not clear enough for me I have some questions about this problem:
|
This is the same problem, the proposed solution on WP.org is working for me. https://wordpress.org/support/topic/uploaded-images-not-showing-in-the-media-library/ |
If you need to sanitize your database, I ran this query, then the images start showing up correctly under WP -> Admin -> Media and in gallery posts. This will only work on MariaDB. Make a database backup before you run it! UPDATE wp_postmeta a SET meta_value = REGEXP_REPLACE(a.meta_value, '20([0-9]{2})/([0-9]{2})', '20\\1/\\2/') where exists (select * from wp_posts b where a.post_id=b.ID and b.post_type='attachment') and a.meta_key='_wp_attached_file' and a.meta_value <> REPLACE(REGEXP_REPLACE(a.meta_value, '20([0-9]{2})/([0-9]{2})', '20\\1/\\2/'), '//','/'); Updating the _wp_attachment_metadata records will break things, do not update it. |
I have a strange behavior when using this plugin, I have imported posts from a Squarespace blog. I import the posts, and the image paths before the plugin is activated are like this:
https://images.squarespace-cdn.com/content/v1/55b3d4afe4b0edbb36a4b6ea/1552236764572-KT58HNL34WDKJYMWFJFX/ke17ZwdGBToddI8pDm48kLzw7P_nKYlGGC0MzqILKf17gQa3H78H3Y0txjaiv_0fDoOvxcdMmMKkDsyUqMSsMWxHk725yiiHCCLfrh8O1z4YTzHvnKhyp6Da-NYroOW3rv7sVmavAApj1cuSnuUyXzqqXjS3CfNDSuuf31e0tVEhpqFMoPGd0_ypppePcJDz-vqyAZGPnUfr_Ql19q21eghW3lgGaAnbOfVbqEfQJYA/Accounts+Payable300dpi--3.jpg?format=original
When I activate the wp-auto-upload plugin, the path is like this:
.../uploads/2019/10AccountsPayable300dpi-3.jpg
The image is saved to disk under this path:
.../uploads/2019/10/AccountsPayable300dpi-3.jpg
It should be uploads/year/month/image.
Instead the path is saved as uploads/year/monthimage (no slash between month and image name)
What is strange is, the image path does get overwritten properly in the edited post, where the original image url got replaced with the imported image url. But since the image url doesn't get saved to the media attachment, you are unable to see the image in the media gallery (a blank thumbnail) and you can not use the image in a different post / page.
I'm using the latest version of the plugin from wordpress.org and the latest stable wordpress release ( 5.2.4 ) I have the classic editor plugin installed if that's relevant. OS is windows, server is Apache.
The text was updated successfully, but these errors were encountered: