Easiest would be to pull it in with Composer, then just follow the instructions on their docs page. It's pretty simple to use. If you need to make some customizations, I'd recommend making a wrapper class for it.

Explain to me in words what you're trying to accomplish. I'm seeing a fair bit of duplication in that code you posted, you've got resolution variables that aren't always defined, etc. Looks like the short of it is you want to upload an image, give it a random name, and resize it to three specific sizes. Is that about right? Anything else? Any errors you're getting?

Admin uploads image banner.jpg.A random set of digits are added at the front to make it unique.The original image remains the same as is uploaded to images/pages/.That image is then resized based on the value of $resize. As some are two across (50/50) and some are four across.

But each are for a 475/768/1920 resolution screen.

As it is resized it is then renamed: banner-475.jpg. banner-768.jpg. banner-1920.jpg.It is stored in the same place as the original.

Then on the consumer page it will use srcset and PHP to establish these filenames, from the original banner.jpg.

Not run this script yet, but thought I would show it here so you can see what I am trying to make happen, based on our original image resizing code.

_________________Love PHP. Love CSS. Love learning new tricks too.All the best from the United Kingdom.

I just tried to run what you posted after adding a simple upload form to it. You've got undefined variables being passed into your resize functions which results in errors being thrown all over the place.

// If we have an uploaded image without errorsif(!empty($_FILES)&&isset($_FILES['image'])&&$_FILES['image']['error']=== 0){$target_directory= __DIR__ .'/images/pages';$pathinfo=pathinfo($_FILES['image']['name']);$prefix=(rand()% 99999999);

// Open the uploaded image with the Imagine library$image=$imagine->open($_FILES['image']['tmp_name']);

Who is online

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum