New answers tagged

0

I think the problem might be that the spread operator is missing in a couple of places. This line: return { meta: { currentMeta, editedMeta }, }; in withSelect should be: return { meta: { ...currentMeta, ...editedMeta }, }; This makes the meta object be a copy of currentMeta (have all the same properties and values), but overwrites them with ...


0

Here is a simple Javascript solution: <script type="text/javascript"> jQuery.noConflict(); jQuery(document).ready(function($){ $('img').each(function(){ $(this).removeAttr('width') $(this).removeAttr('height'); }); }); </script> This can be used to target specific images instead of all images by using a CSS selector, like so: $('....


1

Option 1: force featured image on all posts Use the save_post hook, which runs twice per "save" action if you have revisions enabled. You can verify it's the final run by checking that there is $_POST data (it's empty the first time around). add_action('save_post', 'wpse_force_featured_image', 20, 2); function wpse_force_featured_image($post_id, $post) { ...


0

I know this is very old but I still needed to solve this issue, this may have worked for new images when I used it in functions.php but I did have some issues and images becoming unusable and I also couldn't harness this to update existing images. I had about 2000 existing images I needed to go through them all and make all ofthe old big images smaller. I ...


0

After dealing with this problem for almost a year, I finally solved it. It turned out to be a plugin after all. It was difficult to diagnose, since it happened so sporadically - sometimes not for months. But eventually, I found a certain post which was doing it with some regularity so I copied the site to a dev environment and went through the plugins one at ...


2

You can check mime type of uploaded image before upload to media. Add mimeTypes in $allowmimeType which you want to allow. then check uploaded files mimetype $fileMimeType. If not found in allowed mimetype then return false. // Insert Attachment function insert_attachment($file_handler, $post_id, $setthumb='false') { if ($_FILES[$file_handler]['error'] ...


Top 50 recent answers are included