[英]getting image size gives an error from rss feed
I'm trying to create a default image of my own if an image from rss feed is too small. 如果rss feed中的图像太小,我正在尝试创建自己的默认图像。
this is my code: 这是我的代码:
list($width, $height, $type, $attr) = getimagesize($item['item_img_path']);
if ($width > 75) {
$imgpath= $item['item_img'];
}else{
//no image found - default image
$imgpath = "<span class='fetched'></span>";
}
if ( $width > 75) {
$imgtest = 'image ( '.$width.' ) is larger than 75';
}else{
$imgtest = 'image ( '.$width.' ) is less than 75 <br>path is '. $item['item_img_path'].'<br> type is '.$type;
}
but some of the feeds return media with an extended media url as in: 但是某些提要返回带有扩展媒体URL的媒体,如下所示:
<media:content width="460" url="https://i.guim.co.uk/img/media/330beb5c556c30ab7cba321f3b79241ab7b4d8af/782_922_7183_4310/master/7183.jpg?w=460&q=55&auto=format&usm=12&fit=max&s=a0cb25015876d9b0b7e4abec488f34b7">
now that image shows in my feed, but when i try to get a size ($width) or type it returns a blank. 现在,该图片显示在我的Feed中,但是当我尝试获取尺寸($ width)或键入它时,它将返回一个空白。
I thought I could bypass that by changing this line: 我以为可以通过更改以下行来绕开它:
if ($width > 75) {
to 至
if ( ($width > 75) || ($width ='')) {
but it made no difference still resulting in a false statement and thus giving just my span (default image) 但这并不会导致错误的陈述,因此只给出了我的跨度(默认图片)
so i also tried to pull all the extra trailing data after the "jpg" of the media file, but it still won't give the size of the image: 因此,我还尝试将所有多余的尾随数据提取到媒体文件的“ jpg”之后,但仍无法给出图像的大小:
$s = strstr($item['item_img_path'], 'jpg', true).'jpg';
list($width, $height, $type, $attr) = getimagesize($s);
if ( ($width > 75) || ($width ='')) {
$imgpath= $item['item_img'];
}else{
//no image found - default image
$imgpath = "<span class='fetched'></span>";
}
if ( $width > 75) {
$imgtest = 'image ( '.$width.' ) is larger than 75';
}else{
$imgtest = 'image ( '.$width.' ) is less than 75 <br>path is '. $item['item_img_path'].'<br>s is '.$s.'<br> s type is '.$type;
}
the rss feed causing me problems is: 导致我出现问题的RSS提要是:
https://www.theguardian.com/environment/energy/rss https://www.theguardian.com/environment/energy/rss
an example media file link is: 媒体文件链接示例为:
https://i.guim.co.uk/img/media/330beb5c556c30ab7cba321f3b79241ab7b4d8af/782_922_7183_4310/master/7183.jpg?w=460&q=55&auto=format&usm=12&fit=max&s=a0cb25015876d9b0b7e4abec488f34b7 https://i.guim.co.uk/img/media/330beb5c556c30ab7cba321f3b79241ab7b4d8af/782_922_7183_4310/master/7183.jpg?w=460&q=55&auto=format&usm=12&fit=max&s=a0cb25015876d9b0b7e4ab
this shows an image but i can't get dimensions. 这显示图像,但我无法获取尺寸。
and removing everything after jpg: 并删除jpg之后的所有内容:
https://i.guim.co.uk/img/media/330beb5c556c30ab7cba321f3b79241ab7b4d8af/782_922_7183_4310/master/7183.jpg https://i.guim.co.uk/img/media/330beb5c556c30ab7cba321f3b79241ab7b4d8af/782_922_7183_4310/master/7183.jpg
gives a forbidden error. 给出一个禁止的错误。 so i can't give dimensions. 所以我不能给出尺寸。
You can use the info you have to pull the full-rez image from media.guim.co.uk. 您可以使用必须的信息从media.guim.co.uk中提取全幅图像。 Switch i.guim.co.uk/img/media/ for media.guim.co.uk/ and you'll be good to go: 将i.guim.co.uk/img/media/切换为media.guim.co.uk/,您会很方便:
https://media.guim.co.uk/330beb5c556c30ab7cba321f3b79241ab7b4d8af/782_922_7183_4310/master/7183.jpg https://media.guim.co.uk/330beb5c556c30ab7cba321f3b79241ab7b4d8af/782_922_7183_4310/master/7183.jpg
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.