Show Image in a dropdown field


(Gereon Goldbach) #1

Is it possible to display images in a dropdown box like in a tv? I have a snippet that return a json with value and html source (< img src=“url”>), but I see only the html source. My pictures are on an external server (via api) and are controlled with a database in modx. Thx.


(Mark Hamstra) #2

Not natively, but a custom input type that uses some sort of select system that allows you to display images would be cool. https://docs.modmore.com/en/ContentBlocks/v1.x/Custom_Inputs/Developing_Custom_Inputs.html


(Gereon Goldbach) #3

I looked at your source code for the dropdown field. It may be enough to add style = “background-image: url ()” to the tag < option > and some javascript. I think, after select an option, a preview of the image is not nessary due the thumb is displayed in the dropdown box.

To manage and retrieve the images via api, I have already created a CMP. By @snippet I get now the data as json.

My questions are:
Can @snippet pass parameters? If yes how? Is it possible that I just copy all the files for the dropdown field to create a new input field to have a basis code?