Help to upload post attachments from Ajax
I’ve actually forgotten to create the function for uploading and attaching images. I’ve found the correct method into another question here Uploading Multiple Attachments From Front-End With A Description.
I’ve actually forgotten to create the function for uploading and attaching images. I’ve found the correct method into another question here Uploading Multiple Attachments From Front-End With A Description.
In your functions.php you want to issue a call to set_post_thumbnail_size() https://codex.wordpress.org/Function_Reference/set_post_thumbnail_size As with add_image_size, you provide the target width, height & whether you want the image hard cropped to these dimensions. So, for example, set_post_thumbnail_size(427, 427, true); will crop all your thumbnails to be a maximum of 427px high or wide, depending on aspect … Read more
This probably has to do with the ImageMagick library that WP normally uses to resize images. I’m not sure whether it is possible to modify the standard settings WP applies, but it is possible to define your own. Here is a tutorial for that. You would have to replace the filter in that tutorial with … Read more
Images attached to posts from library link to 404 error page
Get image from parent category
You need the generate_filename method of the image editor class. Like this: $filename = $img->generate_filename( ‘resized’, ABSPATH.’wp-content/uploads/resized-images/’); $image->save($filename); This will save the image, renamed originalname-resized, in the resized-images directory of the upload folder. This does not mean WordPress knows it is there. That depends on the context in which you are calling wp_get_image_editor().
Modify ‘Sizes’ Attribute for Images with Specific Class
Getting custom image size URL in functions
If you check the documentation for media_sideload_image() it returns HTML img tag for the image right away. Alternately it can return just the URL. Note that while this is suitable for immediate use, it’s generally challenging to go back from URL to attachment ID. IDs are much more friendly for many things, such as being … Read more
You need the attachment ID – which is the same as the “thumbnail ID” – not the post ID. It’s confusing. Maybe by WP 5.0 they’ll update the nomenclature! So, I think this’ll work: function attached_image_content( $column_name, $post_ID ) { if ( $column_name == ‘foobar’ ) { //Change the image size from default ‘thumbnail’ here … Read more