doushi1510 2015-05-21 12:59
浏览 15

一些链接的图像不能用于HTML

I have PHP code that generates HTML code which makes a grid of images. The images are taken from links that are generated for each new image, I also add 133x100 at the end of the image link to resize it on the page. My problem is that a seemingly random selection of images won't display, and I just get a broken image symbol. For example:

This is a link to an image that is generated on my page and is displayed.

This is a link to an image that will not be displayed.

I am only allowed to post 2 links, but removing the %20.%20/133x100 from the end of the last link will show what the picture should be.

Here is the part of the code for the image source:

 function display_images(){
    //This cycles through each image and displays it as HTML
    while($row = $item->fetch()){
       Echo "`<img src= '$link[Image_Link] . /133x100' />`"
    }
 }

It is then called here in a class which puts the images in a grid:

<ul class="rig columns-4">
   <?php
       display_images();
   ?>
</ul>

Seemingly about every 2/20 images won't work, and seeing all the links are in the same format, I don't understand why they won't work, and it just seems random.

EDIT: I have noticed that the links that work have 62fx62f at the end of them before the added %20.%20/133x100. If I add it to the raw link in the right place, it makes the image work. But using that generated link, the image still won't load on the page. So using a link with a working image will not work on the page. (This is the same with the raw link without %20.%20/133x100, that links to an image but also won't work on the website)

  • 写回答

2条回答 默认 最新

  • dongsu0308 2015-05-21 13:15
    关注

    When visiting the links, the urls look like this:

    http://www.example.com/image/randomcharacters%20.%20/133x100
    

    The links work without the %20.%20 at the right dimensions, like so:

    http://www.example.com/image/randomcharacters/133x100
    

    This leads me to believe that it may work if you try using the following for the image source instead:

    <img src= '$link[Image_Link]/133x100' />
    

    The full code would look like this, for the while function:

    while($row = $item->fetch()){
        echo "<img src= '" . $link['Image_Link'] . "/133x100' />";
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)