How to grab first image attached to post and display in RSS feed?

i actually just finished working on a site that needed images in his feeds so i ended up using this: function ba_post_image_feeds($content) { global $post,$posts; $first_img = ”; ob_start(); ob_end_clean(); $output = preg_match_all(‘/<img.+src=[\'”]([^\'”]+)[\'”].*>/i’, $post->post_content, $matches); $first_img = $matches [1] [0]; if(!empty($first_img)){ $content=”<div>” . $first_img . ‘</div>’ . $content; } return $content; } add_filter(‘the_excerpt_rss’, ‘ba_post_image_feeds’); add_filter(‘the_content_feed’, … Read more

How can you upload an image from within a settings page?

WordPress provides a convenient function for just this purpose: wp_handle_upload(). Assuming that you already have the appropriate file form field in your settings page, and that you’re using register_setting() for your options, and therefore already have an options validation callback, simply handle the file form field data using wp_handle_upload(). Here’s an example: <?php // Validate … Read more

Use Media Library to manage galleries like Nextgen (with folders, albums, collections, tags, categories, terms…)

I’ve had this same problem for ages and have currently landed on the following combination of plugins to resolve the issue: Media Tags Tag Gallery Cleaner Gallery Additionally, I made two modifications to the tag gallery plugin (to remove TimThumb and allow reverse ordering) This solution still has a lot of downsides including that it … Read more

Preview Image Path in Admin Section

This is not a answer, is an extended comment with the link to the solution. First, while testing, one of my test sites wasn’t showing the Featured Image uploaded to the folder /wp-content/uploads/POST_ID/image_name.jpg. Same problem as the OP. But, it was not displaying any path to the image. And the bug was that the installation … Read more

Filter what image sizes get generated

Picking which image sizes to generate on a per-upload basis is definitely going to be a bit involved. However, if you’re okay with just entirely removing default image sizes, you have a couple of options, as described in this article: The simplest way is to set the default image height and width to ‘0’ at … Read more

Width 100%: Aspect ratio of image

A + C: img.resize-proportionally { max-width: 100%; height: auto; } As an aside, for the above to work, you shouldn’t attempt B. Having width and height attributes in the img tag is good.

WordPress Image Editor doesn’t update thumbs specified with `add_image_size()`

Like it was said, WordPress only generate thumbnails in the new sizes of the new media uploaded. The old images’ thumbs doesn’t get generated automatically. For this situation, I strongly recommend the following plugin: http://wordpress.org/plugins/force-regenerate-thumbnails/ It is pretty simple and unobtrusive. It just adds a new item on the wp-admin menu for you to regenerate … Read more

Image resize with image url

u can use this: function wpse128538_resize($url, $width, $height = null, $crop = null, $single = true) { //validate inputs if (!$url OR !$width) return false; //define upload path & dir $upload_info = wp_upload_dir(); $upload_dir = $upload_info[‘basedir’]; $upload_url = $upload_info[‘baseurl’]; //check if $img_url is local if (strpos($url, $upload_url) === false) return false; //define path of image … Read more