The documentation for the $comment_approved argument was incomplete in a few places in WordPress core, so I’ve submitted a patch: https://core.trac.wordpress.org/ticket/33903
Recent Updates Toggle Comment Threads | Keyboard Shortcuts
-
Christopher Finke
-
Christopher Finke
I (along with Brandon Kraft) debugged a problem in WordPress trunk that was causing comment notification emails to be sent for comments that had been caught as spam.
The resulting bug report and patch are at https://core.trac.wordpress.org/ticket/33587#comment:30
-
Christopher Finke
I’ve posted a code snippet I used to sideload images from Flickr into WordPress, specifically for http://foodirl.com/ I originally stored all of my images on Flickr because I started the blog on Tumblr, knowing that I would move it later (which I did, to Crowd Fusion and then to WordPress).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php /** * Retroactively sideload images referenced from Flickr. */ $flickr_sideload_media_id = null; function flickr_sideload_get_media_id( $media_id ) { global $flickr_sideload_media_id; $flickr_sideload_media_id = $media_id; } function flickr_sideload_init() { global $flickr_sideload_media_id; if ( isset( $_GET['do_flickr_sideload'] ) ) { add_action( 'add_attachment', 'flickr_sideload_get_media_id' ); require_once( ABSPATH . 'wp-admin/includes/media.php' ); require_once( ABSPATH . 'wp-admin/includes/file.php' ); require_once( ABSPATH . 'wp-admin/includes/image.php' ); $offset = 0; $limit = 10; while ( $posts = get_posts( 'posts_per_page=' . $limit . '&offset=' . $offset ) ) { $offset += $limit; foreach ( $posts as $post ) { if ( preg_match_all( '/(?<atag><a[^>]+href="(?<href>[^"]+)"[^>]*>)\s*(?<imgtag><img[^>]+src="(?<src>[^"]+)"[^>]+>)\s*(<\/a>)?/i', $post->post_content, $images, PREG_SET_ORDER ) ) { $post_content = $post->post_content; foreach ( $images as $image ) { if ( strpos( $image['src'], '.flickr.com/' ) !== false ) { $description_matches = array(); $description = ''; if ( ! empty( $image['atag'] ) ) { preg_match_all( '/title="(?<title>[^"]+)"/i', $image['atag'], $description_matches, PREG_SET_ORDER ); } if ( ! empty( $description_matches ) ) { $description = $description_matches[0]['title']; } else { preg_match_all( '/alt="(?<alt>[^"]+)"/i', $image['imgtag'], $description_matches, PREG_SET_ORDER ); if ( ! empty( $description_matches ) ) { $description = $description_matches[0]['alt']; } } $image_html = media_sideload_image( $image['src'], $post->ID, $description ); preg_match_all( '/width="(?<width>[0-9]+)"/', $image['imgtag'], $width_matches, PREG_SET_ORDER ); preg_match_all( '/height="(?<height>[0-9]+)"/', $image['imgtag'], $height_matches, PREG_SET_ORDER ); if ( ! empty( $width_matches ) && ! empty( $height_matches ) ) { $size = array( $width_matches[0]['width'], $height_matches[0]['height'] ); } else { $size = 'full'; } if ( ! empty( $image['atag'] ) ) { $image_html = wp_get_attachment_link( $flickr_sideload_media_id, $size ); } else if ( $size != 'full' ) { $image_html = str_replace( '<img ', '<img width="' . $size[0] . '" height="' . $size[1] . '" ', $image_html ); } $post_content = str_replace( $image[0], $image_html, $post_content ); } } if ( $post_content != $post->post_content ) { wp_update_post( array( 'ID' => $post->ID, 'post_content' => $post_content ) ); } } } } die; } } add_action( 'init', 'flickr_sideload_init' ); Stick it in
mu-plugins
and then loadwp-admin/?do_flickr_sideload
. It doesn’t have lots of error checking, but it worked flawlessly for FoodIRL’s 160+ posts.-
A. I. Sajib
Hi,
Thanks for your comment on my blog. I crawled back to your blog here and was curious if I could ask two questions regarding Flickr images on WordPress.
The first question is, is there any easier way that you know of that lets authors (editors and authors, to be precise) add single Flickr image from a preset account? I found WP Flickr Embed plugin to work exactly how I want it, but I’m hitting Ajax Error repeatedly. I searched their support forum but haven’t found a solution.
Secondly, do you know if there’s any easy way (a plugin would be handy) for us to replace all WordPress featured images (that are used as thumbnails on homepage and elsewhere on the site) by a source URL to a remote image? I store all my images to either Flickr or Google+ and link to them in order to reduce space and bandwidth on my hosting. It would make my life a lot easier if there was a way to not have to upload featured images in order for my posts to have a thumbnail image on the front page. I once worked for a publication that allowed something like this. They would add a custom field and a link to the remote image and that worked. I haven’t figured out how to do this easily.
I understand this can be difficult and may differentiate from theme to theme. But still I’m wondering if you know of any easier solution to either of the questions above.
Thanks for your time and answer.
Regards.
LikeLike
-
Christopher Finke
The first question is, is there any easier way that you know of that lets authors (editors and authors, to be precise) add single Flickr image from a preset account?
I haven’t used anything that does this, but wp-flickr-press looks like it’s probably closest to what you want. Of you can just put the URL to the Flickr photo page (e.g., https://www.flickr.com/photos/cfinke/4291588352/) on its own line in your post, and WordPress will automatically embed it.
Secondly, do you know if thereโs any easy way (a plugin would be handy) for us to replace all WordPress featured images (that are used as thumbnails on homepage and elsewhere on the site) by a source URL to a remote image?
I’m not aware of one, but if you’re ok with hosting the images yourself, you can offload bandwidth to Automattic by using Jetpack’s Photon feature: http://jetpack.me/support/photon/
-
A. I. Sajib
The embedding option is definitely amazing. The only problem is it doesn’t stretch to the full width of the content area. I wish there were ways to do this. I’m going to check out the plugin you linked to. Thanks for the recommendation.
I used Photon for a while but over time the more posts I publish the number of little image files increase on my server causing some sort of issues (I’m not very technically knowledgeable on server side issues). But thanks for your help. Perhaps I can convince someone to develop a plugin for me. ๐
Have a nice day.
LikeLike
-
A. I. Sajib
Hi again,
I just wanted to say the plugin you recommended does exactly what I’m looking for. Though I needed to create an app on Flickr to get the API keys.
I can’t thank you enough for the link. ๐
LikeLike
-
-
-
-
Christopher Finke
Reported a drag-and-drop upload bug in WordPress 4: https://core.trac.wordpress.org/ticket/29689
-
Christopher Finke
A patch I submitted to allow plugins to filter which comment metadata gets included in WordPress export files was committed and included in WordPress 4.0: https://core.trac.wordpress.org/ticket/28745
-
Christopher Finke
Reported a WordPress core bug discovered by my wife:
Image caption disappears if images are rearranged immediately after adding the caption.
-
Christopher Finke
WP_HTTP_IXR_Client strips query string from server URL: https://core.trac.wordpress.org/ticket/26947
-
Christopher Finke
A new plugin and theme for Keyring users
I’ve posted a new plugin that works with Keyring Social Importers to allow you to import activity from Reddit and a lifestreamy theme to show off all of the data that Keyring Social Importers can transfer to WordPress. Soon, you’ll be able to back up the entire Internet to a WordPress blog.
-
Christopher Finke
Version 3 of Formategory is out now; like the recent Inline Preview release, it’s mainly to update the screenshots for WordPress 3.8, but it also incorporates some performance fixes that have been committed over the past year.
-
Christopher Finke
I’ve updated Inline Preview for WordPress 3.8. No functionality changes, but the plugin’s UI fits in better with the rest of the admin, and I fixed one bug with the preview overlapping the post editor.
Reply