Is it possible to insert many images at once to Image DB?

Is it possible to insert many images at once to Image DB?

by Susan Mangan -
Number of replies: 4
Picture of Particularly helpful Moodlers
Helloooo

I am using v1.8.8 and have had a request to be able to add (upload) many images at once.

So far, I have not been able to figure out how to do this. I assume you cannot.

I understand you can import data with .csv but obviously this would not work with images.

I can upload a zip to the files area and unzip, but there is no easy way to associate these images with the database module.

If I am missing anything that would help me to figure this out.. please let me know!

Thanks
Average of ratings: -
In reply to Susan Mangan

Re: Is it possible to insert many images at once to Image DB?

by Itamar Tzadok -

Actually it should be fairly easy to associate the images in the Files area with the database module. In the database you can have a text field for the image file name, say, imageName. Then you import (csv) the image file names (e.g. image001.jpg) into the imageName field. Then you add to the single or list view template or both, an img tag with the image file path and the image name.

For example, suppose your images location in your Moodle files is:

http://your.moodle.org/moodle/file.php/3/images/

You can add to the template the following html:

<img src="http://your.moodle.org/moodle/file.php/3/images/||imageName||" />


(|| stands for square brackets) and the image should be displayed.


Hope this helps smile
Average of ratings: Useful (1)
In reply to Itamar Tzadok

Re: Is it possible to insert many images at once to Image DB?

by Susan Mangan -
Picture of Particularly helpful Moodlers
Worked like a charm!!!  Thanks so much!!!  big grin
In reply to Susan Mangan

Re: Is it possible to insert many images at once to Image DB?

by Susan Mangan -
Picture of Particularly helpful Moodlers

One more thing.. using this method you lose the 'thumbnail' view using the list template.  The more I think about it, the less I feel confident this is doable using this technique - but I've been wrong before... thoughts?  thoughtful

In reply to Susan Mangan

Re: Is it possible to insert many images at once to Image DB?

by Itamar Tzadok -
Well, if you have different images for thumbnails you can simplify things by giving them the same name of the image with a tn prefix (e.g. image001.jpg -> tn_image001.jpg) then in the list view you set the img src to

<img src="http://your.moodle.org/moodle/file.php/3/images/tn_||imageName||" />

If you use the same images you can play with the image width and height properties to reduce the displayed image size (although if the image size is big the page may be quite heavy).

Hope this helps.

smile