-3

When creating a new page I want to select an image from a gallery of all images previously uploaded. I've tried searching for a solution for a few hours but can't seem to find any good answers. I already know how to upload and display the images to a gallery from the database.

What I don't know is how to make it so you can select an image and assign it to that page/content.

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

0

It's not something that happens automatically. You have to code it.

The algorithm would look something like this:

  1. Display thumbnails with the url/id of the full size picture (see Creating a thumbnail from an uploaded image);
  2. On click, add the url of the picture you want to use on that page.
Sylverdrag
  • 8,898
  • 5
  • 37
  • 54
  • Yeah i know. What i dont know is how to code it, so i could use i pointer in the right direction. – Peter Nielsen Nov 21 '19 at 11:15
  • What is it that you don't know? You say you know how to get the pictures from the database. Ok. I assume you know how to display them in HTML, correct? Use the url as the id or some other attribute of the thumbnail image. Now you want to listen to the click event using javascript (in jquery, $('.thumbnail').click()...) and change the value of the "select image" input to the url of the image and submit it along with the rest of the form. If you can pinpoint exactly what you don't know, it will be easier to help you. – Sylverdrag Nov 21 '19 at 11:23