Skip to content

Commit

Permalink
Merge branch 'release/1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ejdanderson committed Apr 17, 2012
2 parents bb89917 + 284a424 commit f5127b1
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 18 deletions.
48 changes: 30 additions & 18 deletions cf-media-rss.php
Expand Up @@ -3,7 +3,7 @@
/*
Plugin Name: Media RSS Image Links
Description: Adds media RSS elements to your RSS2 feed for images attached to posts.
Version: 1.0
Version: 1.1
Author: Crowd Favorite
Author URI: http://crowdfavorite.com
*/
Expand All @@ -12,27 +12,39 @@ function cf_media_rss_links() {
global $post;
$items = get_children(
array(
'post_parent' => $post->ID
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
)
);
foreach ($items as $item) {
$info = wp_get_attachment_metadata($item->ID);
$thumb = wp_get_attachment_image_src($item->ID);
echo '
<media:content
url="'.wp_get_attachment_url($item->ID).'"
type="'.$item->post_mime_type.'"
width="'.$info['width'].'"
height="'.$info['height'].'"
/>
<media:thumbnail
url="'.$thumb[0].'"
width="'.$thumb[1].'"
height="'.$thumb[2].'"
/>
';
if (is_array($items)) {
foreach ($items as $item) {
$info = wp_get_attachment_metadata($item->ID);
$thumb = wp_get_attachment_image_src($item->ID);
echo '
<media:content
url="'.wp_get_attachment_url($item->ID).'"
type="'.$item->post_mime_type.'"
width="'.$info['width'].'"
height="'.$info['height'].'"
>
<media:thumbnail
url="'.$thumb[0].'"
width="'.$thumb[1].'"
height="'.$thumb[2].'"
/>
<media:title type="html">'.esc_html($item->post_title).'</media:title>
<media:description type="html">'.esc_html($item->post_content).'</media:description>
</media:content>
';
}
}
}
add_action('rss2_item', 'cf_media_rss_links');

function cf_media_rss_ns() {
echo 'xmlns:media="http://search.yahoo.com/mrss"';
}
add_action('rss2_ns', 'cf_media_rss_ns');

?>
36 changes: 36 additions & 0 deletions readme.txt
@@ -0,0 +1,36 @@
=== Media RSS Image Links ===
Contributors: alexkingorg, crowdfavorite
Tags: media, rss, images
Requires at least: 3.0
Tested up to: 3.3.1
Stable tag: 1.1

Automatically add Media tags to your RSS2 feed based on images attached to a post.

== Description ==

Media RSS Image Links will automatically add media tags to your RSS2 feed. These media tags are based on the images that are attached to a given post.

== Installation ==

1. Upload the plugin to your blog
2. Activate it
3. Thats it!

== Screenshots ==

== Frequently Asked Questions ==

== Upgrade Notice ==

== Changelog ==

= 1.1 =
* Add in media namespace to Feed
* Only pull images attached to post
* media:content is now a wrapper on the optional elements
* Added media:title and media:description elements
* Added readme

= 1.0 =
* Initial release

0 comments on commit f5127b1

Please sign in to comment.