Jump to content

Recommended Posts

Hello, first time posting

 

Basically I run a WordPress blog which grabs RSS feeds from my other blogs containing Images, Text and Videos

 

I use this code:

 

<?php
$i = 0;
$page = get_the_content();
$doc=new DOMDocument();
$doc->loadHTML($page);
$xml=simplexml_import_dom($doc);
$images=$xml->xpath('//img');
foreach ($images as $img) {
list($width, $height, $type, $attr) = getimagesize($img['src']);

if ($height > 149 ) {
echo '<img src="' . $img['src'] . '" alt=" ' . $img['alt'] . ' - funny pictures" title=" ' . $img['title'] . ' - funny picture dump" onerror=\'this.style.display="none" \'><br>';
$i++;
if ($i == 3 ) { break;}
}
else
{
// don't display
}
}
?> 

 

To replace the "<?php the_content(); ?> peice of code in my index and single.php files. what it does is get only images from my rss feeds and remove all of the text. what I want it do do is allow it to post youtube videos also since almost all of my feeds use both images and videos. when my feed autoposts a video the php gets broken and my wordpress theme gets all weird looking.

 

can someone help me let my feeds post vidoes too?

Link to comment
https://forums.phpfreaks.com/topic/252017-simple-grabing-image-code/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.