A
A
Alexander Shapoval2017-07-07 17:33:57
PHP
Alexander Shapoval, 2017-07-07 17:33:57

How to speed up image output?

Good day, there are N-th number of images, when you hover the mouse over the image, its original size appears

$('.screen').mouseenter(function(event){
        var src = event.target.getAttribute('src');
        $("#multizoom2").attr("src", src);
    });

The images are taken from a third-party resource, when hovering over with the mouse it switches very quickly, but I would like to replace the links of others with my own as if the images are on my server, for this I added the appropriate route and the controller displays the image in the following way
header("Content-type: image/jpeg");
$img_from = imagecreatefromjpeg('https://pdacdn.com/userfiles/screens/' . $id_user . '/' . $id_file . '/' . $screen . '.jpg');
imageJpeg($img_from);

But now when you hover over the image, it switches with a delay of 2 ... 3 seconds. how to speed it up?
Keeping images at home is not an option, and I don’t want to make a temporary cache either, is there another way out?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stalker_RED, 2017-07-07
@Stalker_RED

Preload, aka preload, for example.
Create a hidden img in which you prescribe an image so that by the time you hover it with the mouse it will already be in the browser cache.

W
Wexter, 2017-07-07
@Wexter

I used to travel directly from Moscow to St. Petersburg, but now I started traveling through Latvia, the journey began to take longer, can I somehow get there faster?

A
Andrey Burov, 2017-07-07
@BuriK666

why imagecreatefromjpeg if you can just readfile ?
Well, it's even better to set up proxy_pass in nginx with caching.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question