How Do I Delete All The Images from WordPress

You could try the following, I havent tested it, so look out for typos or errors: $all_posts = get_posts(array( ‘numberposts’ => – 1, ‘post_status’ => ‘any’, ‘post_type’ => get_post_types(”, ‘names’) , )); foreach($all_posts as $all_post) { delete_post_media($all_post->ID); } function delete_post_media($post_id) { if (!isset($post_id)) return; elseif ($post_id == 0) return; elseif (is_array($post_id)) return; else { $attachments … Read more

Add custom setting that uses radio button to WP Gallery

I had the same problem and got it finally to work. Based on the thread you have followed, you now have to extend the “update” function of the WP core /wp-includes/js/media-views.js. Go to the “jQuery(document).ready(function()…” part of the ‘print_media_templates’ action and try this: <script> jQuery(document).ready(function() { wp.media.view.Settings.Gallery = wp.media.view.Settings.Gallery.extend({ // add your custom options template … Read more

Uploading dwg files to wordpress

Your code should work just fine. The only problem in there is that you’ve set incorrect mime type, I guess… It should be image/vnd.dwg. So this one should work: function custom_upload_mimes ( $existing_mimes=array() ) { $existing_mimes[‘dwg’] = ‘image/vnd.dwg’; return $existing_mimes; } add_filter(‘upload_mimes’, ‘custom_upload_mimes’);

Cannot upload .mp3 file to wordpress media

you need to allow them to be uploaded in your media files. you can add following code to your themes functions.php function my_mime_types($mime_types){ $mime_types[‘mp3’] = ‘audio/mpeg’; return $mime_types; } add_filter(‘upload_mimes’, ‘my_mime_types’, 1, 1); there is more information about adding new mime types in WP here: https://wpsmackdown.com/add-remove-filetypes-wordpress-media-library/#add-filetypes And here a list of the mime_types: https://feedforall.com/mime-types.htm

Display “large” image size and show caption in attachment page

I’ve tested the following and it works for me. This uses the image’s Title for the ‘alt’ text and displays the image’s caption below the image itself. Use this in content-attachment.php, replacing the current the_content function: $attachment_id = get_the_ID(); // If this attachment is an Image, show the large size if ( wp_attachment_is_image( $attachment_id ) … Read more

File Type Is Not Permitted – Cronjob

Defining ALLOW_UNFILTERED_UPLOADS isn’t enough anymore: it doesn’t grant the capability, it just permits non-admin users who have the unfiltered_uploads capability to upload any file (except on a multisite). You also need to grant yourself the capability, e.g. from Sebastian’s answer here # # For this, see: wp-includes/capabilities.php > map_meta_cap() # function wpse_6533_map_unrestricted_upload_filter($caps, $cap) { if … Read more

Float images in content

You need to setup CSS settings for alignleft class of your theme: .alignleft, img.alignleft { /* … */ display: inline; float: left; /* … */ } And you need to add editor stylesheet where the same CSS will be presented. Create editor-style.css file in your theme, put content CSS settings there and call add_editor_style(); from … Read more