PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → WB22 - Image Display In Looper
WB22 - Image Display In Looper
Débuté par André Labuschagné, 16 juil. 2018 14:05 - 11 réponses
Posté le 16 juillet 2018 - 14:05
Hi All

I need some assistance with displaying an image in a looper - WebDev. I have created the variable in the looper and assign the jpg to be displayed using a full path thus:

c:\mydata\myjpg.jpg

Nothing displays. Are there any tricks to get this working?

Cheers
André
Posté le 16 juillet 2018 - 14:56
Hi André

you are on the web... LOTS of permissions problems here.
So first, by default, only images BELOW the site directory are usable.
Second, depending on the settings of image/page, etc, you may HAVE TO use a relative path (ie relative to the web site directory).
Third, you may have to use different technique depending on your settings/environment (browser code, server code, ajax or not, etc...)
Fourth, check the image field settings (dynamic) and that you are using an ATTRIBUTE to set the image

Best regards
Posté le 16 juillet 2018 - 16:05
Hi Fabrice

Once again, thanks a ton.

On the development machine I have place the images below the exe folder.

I am not sure what you mean by a relative path.

I am not sure what you mean by different techniques - this looper is loaded in a local procedure.

I think there is where I am all out of kilt. I am simply pointing to the file with a pat variable. What do you mean by using an attribute to set the image.

Cheers
André
Posté le 16 juillet 2018 - 16:42
André,

It's not a good idea to have anything other than exe's under your exe folder. If I remember correctly, WX defaults to put everything under the exe folder in Windows which probably leads people to believe this is a good thing - it's not. This is mainly due to the exe folder having special permissions under Windows.

Relative path is, say your site is in "c:\MySite" and you have images in "c:\MySite\MyImages". The relative path to your images would be "\MyImages" or "\MyImages\myjpg.jpg".

Attributes are what link object/elements of a Looper control to your code and the Looper.Attribute name(s) are what you refer to in your code.

Attributes of a Looper control A Looper control includes: controls, that are repeated on each row. attributes. An attribute is used to define the control characteristic that will be modified on each row. For example, if the value and the color of PRICE control must change on each row, you will have to define two different attributes for the same control. To find out or modify the characteristic of a control (its value, its color, ...), all you have to do is handle this control or the corresponding attribute by programming.
See also:
https://help.windev.com/en-US/…
https://help.windev.com/en-US/…
Posté le 16 juillet 2018 - 17:08
Hi Darren

I have used loopers and images extensively in WDM and it all works as expected.

I cannot even get the image to display in WB. I have tried every possible location - it just does not display.

The LooperAddLine uses a variable for the location of the image on the disk. It does not matter where I place this image. The image exists. The variable is primed with the exact location. Nada.

I cannot even get this to work on the development machine.

Cheers
André
Posté le 16 juillet 2018 - 17:10
Hi

your web site directory is NOT the EXE directory. it's the ProjectName_WEB directory. So you need to put your images in a subdirectory there.

https://www.google.com/search…

If yo don't know what attributes are, then you are not using loopers the right way and you should read the ehlp about them.

Finally, when you are asying 'this looper is loaded in a local procedure. ' you are not telling us anything. BROWSER procedure ? Server Procedure ? Ajax mode procedure ? And where and how is the procedure loaded.

It seems to me that you should start by watching my videos about Webdev, because it looks like you are missing quite a few important points in developing for the web.

Best regards
Posté le 16 juillet 2018 - 17:16
Hi,

It's really difficult to say why, in part becasue of all the complexities Fabrice has mentioned in his post, but also becasue of the different things that need to be considerd and coveyed to forum by yourself so we can help. Maybe some code and how you've implemented it might help (i.e. where you've implemented your code; events, procedures etc...), also where your images are, what permissions they have etc...?

Also, don't know if you've read this Help page?
https://help.windev.com/en-US/…
...and this...
https://help.windev.com/en-US/…
Posté le 16 juillet 2018 - 19:08
Hi Fabrice

I have static images in the correct spot and they are fine. They display.

It is the variable images that I am not getting right. The control is set to dynamic.

I have placed all these images in the project_web folder - I have tried everything along those lines.

I have an idea of what attributes are and have used them extensively, for images in a looper as well, in WD and WDM but not WB. The attribute I have been using has been value. All I have been doing is adding the path of the variable when executing an add line and the image has displayed. But not in WebDev it does not.

The local procedure is Ajax mode procedure. The procedure is called straight after the page is initialized. The other data that is collected at that point is displayed perfectly.

I have about 30 heavily used web apps that use loopers extensively with all manner of data and ajax procedures to verify data integrity. It all works well. I just cannot get an image to display even though the value attribute is pointing to a valid image - the path and file is valid.

I will continue to fiddle with the combinations of what could be wrong.

Cheers
André
Posté le 16 juillet 2018 - 19:12
Hi Darren

I have been through the help a few times.

The static images are not a problem.

The problem I am having is what to pass when adding the looper line. I am passing a full path of where the images are. Elsewhere I pass that with the attribute set to value and it works - WD and WDM. I have tried the attribute image here as well.

Will keep checking for all combinations of what the problem could be.

Cheers
André
Posté le 16 juillet 2018 - 20:29
Andre,

to make sure the looper CAN "find" the image, can you place a single imageocontrol on your page and point that to same path of your images, at the same moment you fill the looper (I presume in some kind of for-each loop?)
It should then show the last image, but it's just for testing to see where in this process something fails.

I have no problem showing images. But in my case they are not coming from a file, but from the database. ie.
i is int
FOR EACH qry_Photos
i++
nRow = LooperAddLine(LOOP_Photos,"Foto " + i)
LOOP_Photos.ATT_Image[nRow] = qry_Photos.Photo.
END
Posté le 16 juillet 2018 - 20:57
Hi Arie

Thanks.

I have now placed an image control on the page.

I assign the image:

IMG_NoName1..Value = "c:\myproject\edubrd\edubrd_web\s15054.jpg"


Nada

Change to IMG_NoName1..Image = "c:\myproject\edubrd\edubrd_web\s15054.jpg"

Nada

This is a dynamic image control. Static works - dynamic does not.

If I could just get one example I would be good to go.

Cheers
André
Posté le 16 juillet 2018 - 22:10
Hi Arie

Thanks mate.

Your advice did the trick

It is all about location and syntax and the testing is different to production.


Cheers
André