Prevent WordPress from adding image’ title automatically

You can try the following to clear the image attachment’s title when it’s inserted but not updated: /** * Empty the image attachment’s title only when inserted not updated */ add_filter( ‘wp_insert_attachment_data’, function( $data, $postarr ) { if( empty( $postarr[‘ID’] ) && isset( $postarr[‘post_mime_type’] ) && wp_match_mime_types( ‘image’, $postarr[‘post_mime_type’] ) ) $data[‘post_title’] = ”; return … Read more

ZIP up all images displayed in a [gallery] and offer as download link

First you have to get the images. How to get all images of a gallery is described here. WordPress uses two classes for unzipping files. The PHP bilt in ZipArchive() (usage see David Walsh). And PclZip, you can found this class in wp-admin/includes/class-pclzip.php. If you got problems with ZipArchive() try the PclZip class. Now you … Read more

Add custom fields to wp native gallery settings

Thanks for your code. I’ve investigated this issue further (this is not an integer formatting problem). The only solution I came up with for number fields is to monkey patch more WP JS. Here is entire code with modifications which supports any input type: add_action(‘print_media_templates’, function(){ ?> <script type=”text/html” id=”tmpl-custom-gallery-setting”> <h3>Custom Settings</h3> <label class=”setting”> <span><?php … Read more

How to manually fix the WordPress gallery code using PHP in functions.php?

Like it was mentioned before removing the shortcode and re-adding it is not the compatible with other plugins modifying galleries so instead you use the post_gallery filter hook and the same code from the gallery_shortcode function but with your own modification for example, I’ve commented out the parts you don’t want: function fix_my_gallery_wpse43558($output, $attr) { … Read more