is it possible to force wordpress to always save thumbnails as ‘jpg’ not ‘png’

Here’s something I wrote because my clients were using very high quality pngs, when they could be more lossy jpgs for web. Note this still preserves the original image, only changes the thumbnails. Add this to your functions.php <?php //Force PNG Thumbnails into JPGs add_filter(‘wp_generate_attachment_metadata’,’force_png_to_jpg’); function force_png_to_jpg($image_data) { $sizes = array(‘thumbnail’,’medium’,’large’); $upload_dir = wp_upload_dir(); $file … Read more

How can I query posts with newly uploaded images?

This should do it for you. If you’re calling it in a function, you’ll of course need to ensure $wpdb is the global. $required_number_of_attatchments = 3; $posts = $wpdb->get_col( $wpdb->prepare( “SELECT posts.ID FROM %s AS posts INNER JOIN ( SELECT MAX(post_modified) AS modified, post_parent FROM %s WHERE post_type=”attachment” AND post_parent > 0 GROUP BY post_parent … Read more

How To Grab All Type Of Attachments, But Images?

WordPress has a function, get_allowed_mime_types, which will return all allowed types. We can filter this list and exclude any types containing image, then query for all remaining types by passing them as a comma separated list to post_mime_type. This may not be the most efficient way to do it, you may be better off filtering … Read more

Link all WordPress images size

You can do this by adding this function to your funcitons.php file. function my_get_image_size_links() { /* If not viewing an image attachment page, return. */ if ( !wp_attachment_is_image( get_the_ID() ) ) return; /* Set up an empty array for the links. */ $links = array(); /* Get the intermediate image sizes and add the full … Read more

save_post not working with attachments

Not really, attachments are still not “full post types”. Manny Flerumond hints this quite well in this thread: Was thinking about this the past few days: currently any media files uploaded to a WordPress site defaults to the post status of inherit, which is a holdover to when media attachments were just that. Media was … Read more

How to send email in wordpress with more than one attachments

Don’t know if that will solve all your problems, but: Generally nicely formatted code is easier to debug. E.g. your code is missing the closing brace. Besides it is better to write if/else(if) statements with braces. Nice indentation helps too. I’d suggest reading the WordPress – PHP Coding Standards. Regarding your code: As noted at … Read more

Add a new data attribute in tag

I found the solution to add that attribute to the img tag with this function: add_filter(‘the_content’,’new_content’); function new_content($content) { $content = str_replace(‘<img’,'<img data-qazy=”true”‘, $content); return $content; }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)