Image url is this possible

I have some images names in a database. For example:
ImageA_1.jog
ImageA_2.jog
ImageB_1.jog
etc

Now what I want to know is there any way of adding a wild card in the image src so it can pull the images for all of ImageA etc (ignoring the _1 & _2 ???

Should be easy if you use a SQL wildcard in the search using %

For example

select * from imagetable where imagename like ā€˜imageA%.jpgā€™

will return
imageA_1.jpg
imageA_2.jpg

but not
imageB_1.jpg

1 Like

Cheers buddy Iā€™ll have a try when I get in the office tomorrow

Hi Brian,

I see what you are saying but how would i put that on for example:

product-images/{{barcode}}.jpg

Currently I have to use product-images/{{barcode}}_1.jpg to get it to work but obviously there are _2, _3 images as well which I want to show in a slider.
I have tried product-images/{{barcode}}% and this does not to work.jpg

I often have this sitation, and need to use the part excluding the ā€˜_1.jpgā€™ etc. as a foreign key - as you do, if I understand correctly.

I add an extra, virtual/generated column in the table, which extracts the part before the delimiter (ie ignores the _1.jpg etc in your example). This is an example expression:
if(locate('-',img_filename),substr(img_filename,1,(locate('-',img_filename) - 1)),substr(img_filename,1,(locate('.',img_filename) - 1)))
(The delimiter in this case is a hyphen)

So the two columns will be:
image

If you are using MySQL, you will need to be using 5.7 (otherwise you could use a trigger). I donā€™t know about other databases.

I imagine this method wonā€™t be required when we can create custom queries. However, there might be advantages in this approach in any case.

Why not use the query builder filters option? Use ā€œcontainsā€ or ā€œstarts withā€ as a condition and the query will return only the records which start with ā€œimageAā€ - then on your repeat region it will only display these images.

OK so update on how I need to do it after going through the database. When we pull the data out of the system it does not reference the barcode.
So what I somehow need to do (I want to do it with the image slider) if somehow pull files from ā€¦/product-images/
in the data base it will have the barcode eg. abc123
How would i pull the files for abc123_1, abc_2, etc
so I can get all the image in the slider.

So do you store image names in the database or just the ā€œabc123ā€ number?
If not - Is every record having the same number of photos?

Also by ā€œimage sliderā€ which component are you referring to?

The wildcard has to be used in the server action then server connect query will return all the matching records. You can use that record set directly as the image source for the swiper

the images are the name of the barcode so example abc123.
When the images get uploaded through another program then upload as abc123_1, abc 123_2 etc
_1 being the default image.

No not all images have the same amount of images.

wanting to use the image slideshow

Are all the images names (abc123_1.jpg, abc123_2.jpg etc) stored in the database or not?

no they are not in the database under abc123_1, abc123_2
(if they were it would be easy)
In the database it is stored as abc123

Basically what I need to do is get some way of filtering the /product-images. folder with anything that contains abc123

The images are saved as the barcode name which is allocated when the product is put in through a different program (basically Iā€™ve exported the data to populate the webstore). Everything is working apart from getting multiple images

So you donā€™t have the filenames in the database and donā€™t know the exact number of images. They are all locatec in a folder on the server and the filename is the barcode plus some suffix.

Then use the list folder action to get all the files in the images folder and use the filter/where formatter to filter them.

Thanks Patrick, Iā€™ve slowly worked that out this morning and have managed to get to work on a single barcode, just got to replace that with a dynamic one (which hopefully will be easy)
But happy days I have a working test :slight_smile:

http://testing2019.thegunnery.com.au/testing.php

@Patrick is there anyway on the slide show to get it to show image loading.
For example on this http://testing2019.thegunnery.com.au/2670/guns-and-ammo/674/browning-x-bolt-hells-canyon-long-range-300wsm-3rnd-mag/
I have a spinner showing whilst the database is executing, but the images take a little longer. So if there a way to show a spinner on the images whilst the images load?