Convert uploaded PNG to JPEG automatically

There is a way, I recommend you combine the imagefx plugin with a custom function , http://wordpress.org/extend/plugins/imagefx/ You can read about it here: http://ottopress.com/tag/gd/ , and use a function like one found here: https://stackoverflow.com/questions/1201798/use-php-to-convert-png-to-jpg-with-compression It would look something like (not tested): imagefx_register_filter(‘custom-name’,’my_custom_filter’); function my_custom_filter(&$image, $outputFile, $quality) { $image = imagecreatefrompng(&$image); imagejpeg($image, $outputFile, $quality); imagedestroy($image); } … Read more

Using “media_handle_sideload” to upload images programmatically does not upload image to Media Library

Your failing and getting a WP_Error object returned before the function runs wp_insert_attachment(). You should always include a check for is_wp_error( $thing ) when calling a function that returns WP_Errors. $result = media_handle_sideload($array, $id); if ( ! is_wp_error( $result ) ) { return $result; } else { var_dump( $result->get_error_messages ); } Your problem will be … Read more

Can I add custom meta for each image uploaded via media-upload.php?

Yes, you can add fields, an example function rt_image_attachment_fields_to_save($post, $attachment) { // $attachment part of the form $_POST ($_POST[attachments][postID]) // $post[‘post_type’] == ‘attachment’ if( isset($attachment[‘rt-image-link’]) ){ // update_post_meta(postID, meta_key, meta_value); update_post_meta($post[‘ID’], ‘_rt-image-link’, $attachment[‘rt-image-link’]); } return $post; } // now attach our function to the hook. add_filter(“attachment_fields_to_save”, “rt_image_attachment_fields_to_save”, null , 2); see more on this post

How to add media from front-end to an existing post?

@AboSami actually answered this question in an older post that was not showing up in my search diligence. While he was actually looking for something else his example code worked great. Here’s the script: <?php $post_id = $post->ID; if ( isset( $_POST[‘html-upload’] ) && !empty( $_FILES ) ) { require_once(ABSPATH . ‘wp-admin/includes/admin.php’); $id = media_handle_upload(‘async-upload’, … Read more

Saving Custom Field in Attachment Window in WordPress 3.5

I wanted to be able to add author information to my attachments and merged this code: http://www.billerickson.net/wordpress-add-custom-fields-media-gallery/ with the one you refer to. I Got it to work fully in the modal window via AJAX. The modified code is as follows: /** * Add Author Name and URL fields to media uploader * * @param … Read more

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