How do I create an alternate RSS feed for tags with custom image sizes for MailChimp?

Filter ‘the_content_feed’ or ‘the_excerpt_rss’ and use a thumbnail image of your choice. Sample code, not tested: add_filter( ‘the_content_feed’, ‘wpse_70249_custom_thumb’ ); add_filter( ‘the_excerpt_rss’, ‘wpse_70249_custom_thumb’ ); function wpse_70249_custom_thumb( $content ) { global $post; $thumb_size=”post-thumbnail”; if ( in_category( ‘orange’, $post ) { $thumb_size = array ( 500, 500 ); } if ( in_category( ‘apple’, $post ) { $thumb_size … Read more

WordPress Image Attachment using remote image

You’ll want to get very familiar with wp_insert_attachment(), download_url() and media_handle_sideload(). It’s a bit lengthy to get into the details here, but it absolutely can be done. I used these methods to create a media tab that allows a user to put in a vimeo/youtube URL which I store in a postmeta and use their … Read more

wordpress get gallery images title

In WordPress attachments are stored as posts so you can use most of the post specific WordPress calls and functions to read/write data associated with the attachment. This applies to post meta data for an attachment as well. So in this case, since you have the post ID ( same as $attachment_id ) you can … Read more

How to keep WP from recompressing Full Size images

Using a filter for jpg_quality will hellp you to set your quality for uplaoded images. add_filter(‘jpeg_quality’, create_function(‘$n’, ‘return 70;’)); In most good implementations of Image Optimization you can find a various usae of ImageOptimization tools such as optimng/jpegtran etc, there a lot of plugins that help you to do that.

How to add image attachment to post from a single meta key (Woocommerce)

I got it now using the following code: //featured image from postmeta function postmeta_img_update() { global $post; // If Custom Post Meta Field for a Image/Thumnail Exists if( get_post_meta($post->ID, “_image”, true): // Get Image Location and File Extention $img = get_post_meta($post->ID, “_image”, true); $ext = substr(strrchr($img,’.’),1); // WordPress Upload Directory to Copy to (must be … Read more

Multiple images in one attachment page

An attachment page is dedicated to a single attachment media item (image, video, audio etc.). You can change it’s behaviour by editing single-attachment.php. However this is not recommended. It is possible to create galleries and insert them in posts. Or install a plugin that displays custom posts as galleries of images.

How can I attach hotlinked images in posts/pages within the same server?

No complete code, but I know you can stick it together. 🙂 Find all post IDs of unattached images (borrowed from wp-admin/upload.php): global $wpdb; $lost = $wpdb->get_col( ” SELECT ID FROM $wpdb->posts WHERE post_type=”attachment” AND post_parent > ‘0’ AND post_parent NOT IN ( SELECT ID FROM $wpdb->posts WHERE post_type NOT IN ( ‘attachment’, ‘” . … Read more