How to remove the images from “Uploaded to this post”?

You have to unattach the images from the post. And that means setting their ‘post_parent’ => 0 in wp_posts database table. The plugin Unattach and Re-attach Media Attachments does exactly this, and it uses the following command to this end: $wpdb->update( $wpdb->posts, array( ‘post_parent’ => 0 ), array( ‘id’ => (int)$_REQUEST[‘post_id’], ‘post_type’ => ‘attachment’ ) … Read more

How can I change the to for lazyload wp smilies

You have to use the same quotes around the src attribute as WordPress uses. So filter the URL like this: add_filter( ‘smilies_src’, function( $src ) { return “”https://wordpress.stackexchange.com/questions/116078/data-original=”$src”; }); And while I was on it, I noticed the doc block for the function translate_smiley() is wrong, so I have written a small patch. 🙂

Custom Image Size in Insert Media

I ended up doing this: add_filter( ‘image_size_names_choose’, ‘jss_custom_image_sizes’ ); function jss_custom_image_sizes( $sizes ){ $custom_sizes = array( ‘customsize1’ => ‘Post Rectangle Image’, ‘customsize2’ => ‘Post Square Image’, ); return array_merge( $sizes, $custom_sizes ); }

Display Gallery Images from Custom Post Type

You can alter the foreach loop as follows, foreach( $gallery[‘ids’] as $attachment_id ) { $image_attributes = wp_get_attachment_image_src( $attachment_id ); if( $image_attributes ) { $src = isset($image_attributes[0])? $image_attributes[0] : ”; if(!empty($src)) { ?> <a href=”https://wordpress.stackexchange.com/questions/118897/<?php echo $src; ?>” rel=”prettyPhoto[pp_gal]”><img src=”https://wordpress.stackexchange.com/questions/118897/<?php echo $src; ?>” alt=”Gallery image” /></a> <?php } } } You can specify required dimension, as … Read more

Insert images into wordpress post with a query

Yes, it is possible, WordPress does not have an API, but some useful functions. I would load all your rows into array like $your_table = [‘post_id’ => ‘image’, ‘post_id’ => ‘image’, …] Then execute a foreach loop foreach($your_table as $post_id => $image) { //full path to the image $image_path = _YOUR_FULL_ABSOLUTE_PATH.$image; /** * Get an … Read more