Preloading images

28 views
Skip to first unread message

Colin Smith

unread,
Jun 28, 2022, 5:04:51 PM6/28/22
to Minno.js
Hi all,

I just found out about this group (or, more likely, was reminded about it) and I'm very happy about it.

I hope to not be too much bother :-)

So, I made a questionnaire in which participants can choose between two people to work with. In some conditions, they do this very quickly. However, the images don't load very quickly so sometimes the timer ends and the images haven't loaded yet.

[First, the actual right answer is to make this task within MiTime, but I'm not good enough to do that - and/or I don't have enough time to get good enough to do that]. 

Preloading the images seems like the right thing to do. Yoav sent me the information on how to do that: https://minnojs.github.io/minno-quest/0.0/manager/API.html#preloadimages.

Based on that information, I had made this section:

  API.addSettings('preloadImages', ['bf001.jpg','bf009.jpg','bf010.jpg','bf014.jpg','bf028.jpg','bf033.jpg',  'bf037.jpg','bf048.jpg','bf201.jpg','bf205.jpg','bf206.jpg','bf210.jpg','bf221.jpg','bf244.jpg','bf253.jpg','bm002.jpg','bm005.jpg','bm021.jpg','bm026.jpg','bm029.jpg','bm041.jpg','bm200.jpg','bm201.jpg','bm210.jpg','bm227.jpg','bm229.jpg','bm232.jpg','bm240.jpg','bm242.jpg','bm246.jpg','bm251.jpg','wf009.jpg','wf011.jpg','wf014.jpg','wf017.jpg','wf020.jpg','wf021.jpg','wf025.jpg','wf038.jpg','wf205.jpg','wf208.jpg','wf209.jpg','wf213.jpg','wf214.jpg','wf218.jpg','wf224.jpg','wf231.jpg','wf243.jpg','wf245.jpg','wf247.jpg','wm011.jpg','wm016.jpg','wm022.jpg','wm032.jpg','wm033.jpg','wm200.jpg','wm205.jpg','wm208.jpg','wm210.jpg','wm213.jpg','wm214.jpg','wm218.jpg','wm219.jpg','wm229.jpg','wm244.jpg','wm247.jpg','wm251.jpg','wm254.jpg' ]);


However, I tried it in the consent form and it either doesn't work there or participants aren't on that page long enough to load all the images.

If I put it in the manager file, do you think it will load throughout the study? The task is near the end, so that would likely work if so.

Alternately, I could probably put the images into the IAT file because that file won't start until the images are loaded. The IAT always precedes the relevant task, so that would work. However, I tried to drop it in all over the place and always got an error. Maybe I can put it in the iat8.js file and put that file in my local folder? I'm always afraid to touch that file...

Anyway, sorry for my confused rambling. If you have any ideas about preloading images, I'd really appreciate it! Best, Colin.


Mayan Navon

unread,
Jun 29, 2022, 1:40:26 AM6/29/22
to Colin Smith, Minno.js

Hi Colin,

Yes, it’s best to put this in the mgr file, so it will run before the study starts.
You’ll need to give the function the url to your images directory. For example:

    API.addGlobal({
        mediaURL: '/implicit/user/mayanna/groupeffect1/images/'
    });

*Replace btarget + ‘#.jpg’ with e.g., ‘bf001.jpg’

 var imagesArray = [
    ];
    imagesArray.push(global.mediaURL + btarget + '1.jpg');
    imagesArray.push(global.mediaURL + btarget + '2.jpg');
    imagesArray.push(global.mediaURL + btarget + '3.jpg');
    imagesArray.push(global.mediaURL + btarget + '4.jpg');
    imagesArray.push(global.mediaURL + btarget + '5.jpg');
    imagesArray.push(global.mediaURL + wtarget + '1.jpg');
    imagesArray.push(global.mediaURL + wtarget + '2.jpg');
    imagesArray.push(global.mediaURL + wtarget + '3.jpg');
    imagesArray.push(global.mediaURL + wtarget + '4.jpg');
    imagesArray.push(global.mediaURL + wtarget + '5.jpg');
    imagesArray.push(global.mediaURL + 'iat.jpg');

    API.addSettings('preloadImages', imagesArray);

--
You received this message because you are subscribed to the Google Groups "Minno.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minnojs+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/minnojs/6e3ba247-f9eb-4e80-9aee-ec6c7dff1744n%40googlegroups.com.

Smith,Colin T

unread,
Jun 29, 2022, 9:41:31 AM6/29/22
to Mayan Navon, Minno.js

 

Hi Mayan,

 

I’m happy to know there’s a solution – thank you for your help! Unfortunately, I made those edits and am getting an error. It says the global is not defined. That’s also the syntax error I get on each of the images (e.g., starting at line 18). The same thing happened when I deleted the first global (I don’t know what that’s there for – it’s just always in this file). Any ideas? Best, Colin.

 

 

 

 

From: Mayan Navon <navm...@gmail.com>
Sent: Wednesday, June 29, 2022 1:40 AM
To: Smith,Colin T <colin...@ufl.edu>
Cc: Minno.js <min...@googlegroups.com>
Subject: Re: [Minno.js] Preloading images

 

[External Email]

Mayan Navon

unread,
Jun 30, 2022, 3:07:48 AM6/30/22
to Smith,Colin T, Minno.js
Hi,

You also need to define global at the beginning of your script. This allows you to later define global variables = variables that are recognized across scripts, rather than just the current script you are running.

define(['managerAPI'], function(Manager){

var API = new Manager();

API.addSettings('skip', true);

API.setName('mgr');

    var global = API.getGlobal(); 

You don't need both baseURL and mediaURL. Just use one of them, and stick with it (e.g., in your preload function and later in the IAT).

To inspect the error in the preload part, have a look at the 'syntax' tab.



Reply all
Reply to author
Forward
0 new messages