Storing to a Media Field

Hi all,

I have a Field in a Table named as image and have the data type as Media.

I want to store an Image to this “image” field. The Image strored in the media as test.jpg.

image = ‘media:///p.png’;

Not working…??

Is there any way?

Thanks Acer

You want to store an image from the Servoy media library in a db field? I am asking, because this sounds like a one time job!? If yes, this should work:

image = plugins.images.getImage('media:///p.png').getData();

Usually people want to store images from a file rather than the media library…

Hi Acer,

First of, ‘media:///’ is used to load any image media you have in your solution. I.e. the images that are part of your solution.

Now if you want to load an image file then you need to use the file or the image plugin to load the data of this image. You store the data into the media field.
Search the forum, there are a bunch of threads that cover that.

Hope this helps.

Hi patrick & Robert,

Thanks for your quick reply.

patrick:
If yes, this should work:

image = plugins.images.getImage('media:///p.png').getData();

It is not working.

My intention is to add a media image at the runtime while populating data to a table. It will be much more easier if that image is in the media library.

Is there any technique to the above.

Again Thanks for your response.

Regards Acer.

Teh Servoy media library can only be altered at designtime, which means through Servoy Developer.

Paul

The code I gave you works for me!? I think I don’t really understand what you want to do.

  • do you want to store an image something in the database?
  • or do you want to fill the Servoy media library “on the fly”? (the see Paul’s reply)