<tfoot id='Dt6Nq'></tfoot>
  1. <small id='Dt6Nq'></small><noframes id='Dt6Nq'>

    • <bdo id='Dt6Nq'></bdo><ul id='Dt6Nq'></ul>

  2. <i id='Dt6Nq'><tr id='Dt6Nq'><dt id='Dt6Nq'><q id='Dt6Nq'><span id='Dt6Nq'><b id='Dt6Nq'><form id='Dt6Nq'><ins id='Dt6Nq'></ins><ul id='Dt6Nq'></ul><sub id='Dt6Nq'></sub></form><legend id='Dt6Nq'></legend><bdo id='Dt6Nq'><pre id='Dt6Nq'><center id='Dt6Nq'></center></pre></bdo></b><th id='Dt6Nq'></th></span></q></dt></tr></i><div id='Dt6Nq'><tfoot id='Dt6Nq'></tfoot><dl id='Dt6Nq'><fieldset id='Dt6Nq'></fieldset></dl></div>
  3. <legend id='Dt6Nq'><style id='Dt6Nq'><dir id='Dt6Nq'><q id='Dt6Nq'></q></dir></style></legend>

    1. SimplePie 可以从提要中抓取图像吗

      时间:2023-09-24
            <tfoot id='m0MP1'></tfoot>
          1. <small id='m0MP1'></small><noframes id='m0MP1'>

              <tbody id='m0MP1'></tbody>
          2. <i id='m0MP1'><tr id='m0MP1'><dt id='m0MP1'><q id='m0MP1'><span id='m0MP1'><b id='m0MP1'><form id='m0MP1'><ins id='m0MP1'></ins><ul id='m0MP1'></ul><sub id='m0MP1'></sub></form><legend id='m0MP1'></legend><bdo id='m0MP1'><pre id='m0MP1'><center id='m0MP1'></center></pre></bdo></b><th id='m0MP1'></th></span></q></dt></tr></i><div id='m0MP1'><tfoot id='m0MP1'></tfoot><dl id='m0MP1'><fieldset id='m0MP1'></fieldset></dl></div>

              <bdo id='m0MP1'></bdo><ul id='m0MP1'></ul>
            • <legend id='m0MP1'><style id='m0MP1'><dir id='m0MP1'><q id='m0MP1'></q></dir></style></legend>

              • 本文介绍了SimplePie 可以从提要中抓取图像吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在使用这个 simplepie,并且已将文件上传到我的主机.除了一件事外,一切似乎都运行良好.我从中获取提要的博客中有图像,当我使用 simplepie 查看提要时,图像不显示.当我使用 simplepie 查看博客时,有没有办法让图像显示出来?

                I am using this simplepie and i have uploaded the files to my host. Everything seems to be working fine except one thing. The blog that i'm getting the feed from has images in it, and when i use the simplepie to view the feed, the images don't show up. Is there a way to get the images to show up when i view the blog with simplepie?

                好的,对不起,我是新手.我只是直接使用网站上的代码来尝试查看博客.我会把代码放在这里的底部.所以是的,就像我说的那样,我只是想让图像显示在我正在阅读的博客上.除了那个之外,一切都很好.

                Okay i am sorry, i am new at this. I am just using the code straight from the website to try and view the blog. i will put the code at the bottom here. So yea like i said i'm just trying to get the images to show up that are on the blog i'm reading from. Everything shows up great except that.

                --- 头信息---

                <?php
                
                // Make sure SimplePie is included. You may need to change this to match the location of simplepie.inc.
                require_once('simplepie.inc');
                
                // We'll process this feed with all of the default options.
                $feed = new SimplePie();
                
                // Set the feed to process.
                $feed->set_feed_url('http://wordpress.homickdesign.com/feed/');
                
                // Run SimplePie.
                $feed->init();
                
                // This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it).
                $feed->handle_content_type();
                
                // Let's begin our XHTML webpage code.  The DOCTYPE is supposed to be the very first thing, so we'll keep it on the same line as the closing-PHP tag.
                ?>
                

                --- 代码---

                <h2><a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_description(); ?></a><br />
                      <span>Latest news from Robert Homick</span></h2>       
                
                        <?php
                $c=1;   
                foreach ($feed->get_items() as $item):
                if($c <= 3){
                ?>
                
                        <p><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a><br />
                        <?php echo $item->get_description(); ?><br />
                        <span>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></span><br />
                        <?php $c++;?>
                
                
                <?php } endforeach;  ?>
                

                推荐答案

                是的,您可以调用 get_content() 并将整个帖子或包含在提要中的帖子部分输出到屏幕上,所有包括 HTML 标签.如果你想拉出帖子中的第一张图片,你必须做更多的工作,这是我一直在做的.

                Yes, you can call get_content() and the entire post or the portion of the post that is included in the feed will be outputted to the screen, all the HTML tags included. If you want to pull say the first image in the post, you have to do a little more work, here is what I've been doing.

                $htmlDOM = new simple_html_dom();
                $htmlDOM->load($item->get_content());
                $image = $htmlDOM->find('img', 0); 
                $html .= '<img src="thumbnail.php?file=' . $image->src . '&maxw=300&maxh=300" border="0" />';
                

                我目前的小项目中的片段,使用 simple_html_dom 和另一个我从互联网上获取的脚本来即时调整图像大小.如果您只想显示图像根本不调整其大小 $image->src 是 URL.我认为这样的功能将来可能会添加到 SimplePie 或作为 SimplePie 的附加组件,但同时,显示来自提要的项目的第一张图像需要四行代码.

                That snippet from my current little project, uses simple_html_dom and another script I got off the Internet to resize images on the fly. If you just want to display the image not resize it at all $image->src is the URL. I think functionality like this may be added to SimplePie in the future or an add-on to SimplePie, but in the mean time, it is four lines of code to display the first image from an item from a feed.

                这篇关于SimplePie 可以从提要中抓取图像吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:在 PHP 中导入类和命名空间:前导反斜杠有什么区 下一篇:php 评估后的 PHP file_get_contents

                相关文章

                最新文章

              • <small id='MJ7Ye'></small><noframes id='MJ7Ye'>

                    <legend id='MJ7Ye'><style id='MJ7Ye'><dir id='MJ7Ye'><q id='MJ7Ye'></q></dir></style></legend>
                      <bdo id='MJ7Ye'></bdo><ul id='MJ7Ye'></ul>
                  1. <i id='MJ7Ye'><tr id='MJ7Ye'><dt id='MJ7Ye'><q id='MJ7Ye'><span id='MJ7Ye'><b id='MJ7Ye'><form id='MJ7Ye'><ins id='MJ7Ye'></ins><ul id='MJ7Ye'></ul><sub id='MJ7Ye'></sub></form><legend id='MJ7Ye'></legend><bdo id='MJ7Ye'><pre id='MJ7Ye'><center id='MJ7Ye'></center></pre></bdo></b><th id='MJ7Ye'></th></span></q></dt></tr></i><div id='MJ7Ye'><tfoot id='MJ7Ye'></tfoot><dl id='MJ7Ye'><fieldset id='MJ7Ye'></fieldset></dl></div>

                  2. <tfoot id='MJ7Ye'></tfoot>