doujie4050 2018-07-31 00:34
浏览 76
已采纳

从WordPress网页上的目录中分页所有图像

I need to show in a PHP web page all the images in a folder. A pagination is required. The images can be more than 10,000, so a good performance is important, and here is where my doubt comes from, what is more efficient?

  • Paginate the images of the folder using scandir.

  • Automatically save the name of all images in a database and load them with a Mysqli query (probably also convenient to use a temporary cache).

  • Any other suggestions you can give me.

The website uses WordPress as the engine, but the images are uploaded to a subdomain using a PHP file isolated from Wordpress ...

I thought about saving the name of all the images like a WordPress Custom-Post-Type (using mysqli basic queries) and paginate them like any other publication, but I think that, due to the amount, it would harm the overall performance of the website (because the custom-post-type are saved in the same table as the other publications)...

The website receives more than 30 thousand daily visits that it must support.

PD: Sorry for the bad explanation but it is complicated to explain, and more in another language.

  • 写回答

1条回答 默认 最新

  • douxiong5972 2018-07-31 06:32
    关注

    Use a custom table or a second database.

    You are right to consider avoiding repeatedly calling scandir for every paginated request. You can access the global $wpdb object and do custom queries to manage the contents of your directory.

    I'd lean towards just managing the image data separately from WordPress. Since you are already using a non WP upload script just create a new DB and use it to keep track of the directory contents in that script. Then paginated results is a very simple DB query. This keeps the WP database smaller and faster and is not overkill for the magnitude of images and visits you must handle.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services