shortster
Member
Posted 1 year ago #
When I create a post in the normal way and upload an image through the new post 'add an image' button everything goes fine. In the media-library I see the image is attached to the post and the image gets smushed.
However if I upload an image through for example the commentbox (via a plugin) on the frontend of my website, the image gets uploaded to the media-library but the smush.it column says:
"could not find /home/mysite/domains/mysite.com/public_html/wp-content/uploads/http://www.mysite.com/wp-content/uploads/2011/03/theimage.jpg"
Note: the image is not attached to a post (unattached). Don't know if that's good or bad..
Any idea what's wrong here?
shortster
Member
Posted 1 year ago #
Found the error. When manually adding an uploaded image to the media library, you use:
wp_insert_attachment( $attachment, $filepath);
and
wp_generate_attachment_metadata( $attach_id, $filepath );
Where $filepath needs to be the absolute path. I used the url. With the url in the metadata of the image WP Smush.it tried to locate the image at
absolutepath + url = /home/mysite/domains/mysite.com/public_html/wp-content/uploads/http://www.mysite.com/wp-content/uploads/2011/03/theimage.jpg
Hope it makes sense :)
José Luís
Member
Posted 10 months ago #
It makes sense. But how do we fix it? I'm not using a plugin, only WP Media Library upload function and this error keeps showing.
Any news on this topic?