Feedwordpress – Displaying attached images

Feedwordrpress is a wordpress plugin that syndicates content from RSS feeds to your blog. This is one of the best wordpress plugin if you wish to create an auto blog.
Normally Feedwordpress syndicates images within feeds. But some feeds provide images as attachments of the feed. These images are not shown in the posts created with syndicated posts. But the details of the attachment is saved as a custom field of the post.
Here is a code to display the images attached to the feed. Place this code within The Loop where you want image to be displayed.
<?php $enclosure = get_post_meta($post->ID , 'enclosure', $single = true); ?> <?php $image=explode(chr(10),$enclosure); ?> <?php if(!is_null($image)) : ?> <img src="<?php echo $image[0]; ?>" alt="<?php the_title_attribute(); ?>" /> <?php endif; ?>
This will display the attached image. You can further customize the display of the image by applying css styles to the image.
note: I have updated the code. If you have used the previous code try using the new code above.


December 24th, 2010 - 03:29
Many thanks for your script! Is very usefull :-D
January 4th, 2011 - 20:09
You are welcome :)
January 19th, 2011 - 00:41
Could you be a little more specific about where this code would go?
January 19th, 2011 - 07:41
In index.php, single,php, achieve.php files of your theme, there is a code like this;
< ?php while (have_posts()) : the_post(); ?>
…
…
…
< ?php endwhile; ?>
Add the code mentioned in above between these codes.
January 27th, 2011 - 15:56
don’t work under A Thematic Child Theme… Help?
February 21st, 2011 - 10:19
Have you placed the code correctly?
February 1st, 2011 - 08:01
Tried adding this…get “Parse error: syntax error, unexpected ‘”‘ in /home/user/public_html/wp-content/themes/tribune/index.php on line 112″…any thoughts? Thanks!
February 1st, 2011 - 10:12
Make sure you have added the code correctly. This worked for many people without any error
February 15th, 2011 - 20:30
hi,
how would this work for audio enclosues, i am using feedwordpress and need to grab the enclosures from http://tatw.co.uk/podcast.xml, they don’t display in my posts so far and i have tried adding ID, ‘enclosure’); ?> to my post.php template file
thanks.
February 19th, 2011 - 22:51
Above code is only for images. It won’t work with any other files.
For mp3 files try this code
update: try this code
March 27th, 2011 - 09:51
For the mp3 enclosure…I’d like the text in the link to reflect ideally the title of the post or the name of the mp3. Right now the enclosure is ‘.$media.’ Is there a piece of code I can stick in there so it get’s the title/author of the post. I tried several pieces of WordPress code from the codex but none have worked like . Here’s an example of what I’m trying to do, maybe it will make sense if you see it in full (obviously this doesn’t work though):
ID , ‘enclosure’, $single = true);
$media=strtok($enclosure,chr(10)); ?>
<?php $url=' | ‘;
echo($url); ?>
March 27th, 2011 - 09:51
ID , 'enclosure', $single = true);$media=strtok($enclosure,chr(10)); ?>
<?php $url=' | ';
echo($url); ?>
March 27th, 2011 - 11:49
try this code
update: try this code
March 27th, 2011 - 16:55
Thanks! It strangely half works. It drops in the title which is great…but then the href link ceases to become linkable. An ideas on how to revive the link?
March 27th, 2011 - 20:01
check the code again. seems it works.
March 28th, 2011 - 00:57
it works in having the title show up but it loses the link to the media and becomes static text. Maybe it’s my theme, may try and switch and see if that will do the trick. My hunch for what I need is that just like you’re using the ‘.$media.’ within the href html I need something formatted like that to grab the title instead. Something like ‘.$title.’ (except that doesn’t work, i’ve tried…i’m not familiar with that convention though…do you know of one I could try?
April 6th, 2011 - 13:00
I’ve tried my darndest to get the title code to work. the .title(). definitely doesn’t work on my site…for some reason it loses the link when I put that in. Here’s a page with an example of the enclosure working: http://www.artronica.info/2011/03/27/jason-paul-boy-acapella-improvox-march-25-2011/
I’d love to have that looong link take on the text of the title so it looks better/more readable. I’ve scoured the web for other solutions but yours is definitely the best…if I could only get that mp3 link to have the title text. I think it’s not quite as simple as dropping in the title, I think I need to define a few more variables…just not sure which ones
April 6th, 2011 - 14:06
try assigning the title to a variable & adding it to the code
something like this
April 6th, 2011 - 20:07
no luck. I’d tried some similar stuff. It won’t allow any other text to be hyperlinked except for $media for some reason. I’m guessing I may have to find a way to reorganize this code so it allows other variables inside the hyperlink text.
March 16th, 2012 - 20:08
I have updated the code. try the new code.
March 14th, 2011 - 22:05
Could someone please do an idiots guide how to do this, I’m not familiar with the loop and editing php files.
Thanks.
March 19th, 2011 - 14:23
This is just a copy & paste work. It won’t be much hard. Anyway if you are not much sure about what you are doing, it’s better you get someone else to do this for you.
March 26th, 2011 - 02:42
It definitely works…but I’m having a bit of a problem which may be particular to how I want my site to work. For whatever reason it attaches the link to the mp3 just outside of my Content area instead of firmly inside it. This means that I can’t target the audio with any audio skins or in my case just wanting Yahoo Media Player to see it.
March 26th, 2011 - 08:10
try moving the code more top from the current place you have placed it.
March 27th, 2011 - 03:29
I’ve found that the Yahoo Media player issue was unrelated to this piece of code. The issue is still seems that I can’t get it to nest squarely inside the post. I’m also using the add-this social plugin and when I insert this code the audio link appears unattractively on top of the addthis share module. It is possible that the problem is actually with the Addthis plugin which opens a different can of worms. May just need to use CSS to shift these things around in a suitable manner.
March 27th, 2011 - 07:15
yes, I think you can fix this by using css.
April 1st, 2011 - 09:04
I’m running FeedWordPress, but I am having trouble figuring this out… mainly due to my site configuration I suppose.
I’m running a StudioPress theme, which actually runs off of 2 different themes at once, so editing files is a pain to begin with.
I’ve looked in every single file in both themes (most of the files just point to the other theme and vice-versa) and the only one I have in my theme that includes the (have_posts()) is loops.php – which you would assume would make sense
I’ve added the code there, but no luck… I guess this is a little trickier to implement when you aren’t using a standard WordPress theme.
Any help would be greatly appreciated.
You can view my feed here: http://loopana.com/feed/
I just want to make the attachments show up in the feed, instead of those ugly notepad looking links.
April 1st, 2011 - 18:55
Could you give me the link to your wordpress theme. So I can help you if possible.
February 6th, 2012 - 00:12
Hello,
I tried to insert your code but RSS are still without photos.
Can you help me please?
February 6th, 2012 - 07:27
could you please try copying & pasting the code again. Make sure it’s within the loop.
February 6th, 2012 - 14:02
Hi again,
This is the code for index.php, can you tell me where I’m wrong please?
Thank you very much
<?php
if(have_posts()) {
/* Display navigation to next/previous pages when applicable */
if ( theme_get_option('theme_' . (theme_is_home() ? 'home_' : '') . 'top_posts_navigation' ) ) {
theme_page_navigation();
}
/* Start the Loop */
while (have_posts()) {
the_post();
get_template_part('content', get_post_format());
ID , ‘enclosure’, $single = true); ?>
<img src="” alt=”" />
}
/* Display navigation to next/previous pages when applicable */
if (theme_get_option(‘theme_bottom_posts_navigation’)) {
theme_page_navigation();
}
} else {
theme_404_content();
}
?>
February 6th, 2012 - 14:04
/* Start the Loop */
while (have_posts()) {
the_post();
get_template_part(‘content’, get_post_format());
ID , ‘enclosure’, $single = true); ?>
<img src="” alt=”" />
}
/* Display navigation to next/previous pages when applicable */
if (theme_get_option(‘theme_bottom_posts_navigation’)) {
theme_page_navigation();
}
} else {
theme_404_content();
March 16th, 2012 - 08:41
Hi, I’m trying to implement this on a client’s blog page, which is a news syndication using FeedWordPress. Your code should work in theory, and does work for the LAST excerpt on the page (not a single post page, its a series of excerpts one after another). I’m trying to figure out why it’s only working for the last article and not all of them.
Anyone?
March 16th, 2012 - 18:02
I have updated the code. try the new code & check.
March 17th, 2012 - 04:01
Hi, I am wanting to use feedworpress to create a post from my libsyn podcast RSS feed, including posting the media into the blubrry powerpress enclosure in my wordpress post.
Do you know if this is possible?
Thanks
Ben.
March 17th, 2012 - 05:17
after struggling with this all night i came up with an alternative solution by creating a custom field out of the media enclosure which matches the name of that used by my theme, which works great. your code could come in handy in other situations though, so thanks for looking into that so quickly!
March 17th, 2012 - 07:50
great! would you like to share it with other users here?