Check for gallery api reference
Hi,
The original file name is lost once the user submits the form (or file).
You can get the filename (and size) then store it manually by calling $w(‘#uploadButton’).value once a file has been selected (by registering the onChange )
Can I have some help with this too please. I have no idea what I am doing wit the code part. I have everything done except the code to make it work/pull from the dataBase. (each row has x amount of images and only want that rows images to show) Here is the dynamic page link. thanks so much. I added that code that was provided on here but I really don’t know what to chanage to make it work. In the database i labeled all the fields image1 etc with no spaces. The actual images have whatever name that it had originally. https://rick6367.wixsite.com/fabvisual2/whatwedo/3D-Props-%26-Sculptures
please help me out…
import wixData from ‘wix-data’;
$w.onReady(function() {
wixData.query(‘Queensland’)
.find().then(result => {
//Get data of the first row
const rowInDatabase = result.items[0];
//Creating array for images to put it gallery
const imagesToShow = ; //going over all fields in the row
for (let key in rowInDatabase) {
//assuming images fields have the word ‘image’ in them
if (key.includes(‘image’)) {
imagesToShow.push({src: rowInDatabase[key]}); }
}
$w(’ #gallery1 ').items = imagesToShow;
});
});
In which line and how should i change to getCurrentItem()
can you please rewrite the code using getCurrentItem() ???
Dear Liran I am very new to this and i have no idea about the codes actually. I tried your suggestion however I donot know where to put the dynamicdatgaset and getcurrentitem functions.
I have a dynamic item page and every item has variable number of fotos. (10 to 20 photos for each) I named them all with names 'image1 image2 image3 etc. however I cannot put the dynamic dataset and getcurrentitem functions.
Could you tell where to insert dynamicdataset and getcurrentitem() ?
Thanks
Dear Liran
I am very new to this and i have no idea about the codes actually. I tried your suggestion below
import wixData from ‘wix-data’;
$w.onReady(function() {
wixData.query(‘Queensland’)
.find().then(result => {
//Get data of the first row
const rowInDatabase = result.items[0];
//Creating array for images to put it gallery
const imagesToShow = ; //going over all fields in the row
for (let key in rowInDatabase) {
//assuming images fields have the word ‘image’ in them
if (key.includes(‘image’)) {
imagesToShow.push({src: rowInDatabase[key]}); }
}
$w(’ #gallery1 ').items = imagesToShow;
});
});
however I don’t know where to put the dynamicdataset and getcurrentitem functions.
I am preparing a portfolio like website. For every portfolio I have a dynamic item page and every portfolio has variable number of fotos. (10 to 20 photos for each) I named them all with names 'image1 image2 image3 etc. however I cannot put the dynamic dataset and getcurrentitem functions.
Could you tell where to insert dynamicdataset and getcurrentitem() in the codes you mentioned before?
Thanks
perfect, thanks!!!
Hi Guys,
I am trying to do something similar. I am also very inexperienced at coding and have tried to work it out myself.
I have created a dynamic page. I have a Collection called “Properties”. On each row I have an unspecified number of pictures I want to display in the Gallery. I have added the GetCurrentItem() for the Dynamic link to the correct row. All the image fields are named “Picture1”, “Picture2”, “Picture3”,… The pictures are uploaded so there is no file name sequence or format. The Gallery ID is gallery1. Below is the code I have compiled:
Below is the error I get in the preview:
If there is any other information you need please let me know.
Thanks,
Grant
The dataset’s getCurrentItem() function does not return a Promise, and directly returns the current item (the current row in the database), so you can use the result without .then() . You can do something like this:
let rowInDatabase = $w("#datasetProperties").getCurrentItem;
It’s not clear to me what you’re trying to do with the rest of the code, but at least now you’ll get the proper result in the rowInDatabase variable.
Hi Yisrael,
Sorry I am VERY new to this but have tried to work it out from what I’ve read. I have looked at the API Reference for assistance. Let me go into more detail.
I have created a dynamic page to display each property with details and pictures in a gallery. I have created a Data Collection called Properties with fields for details of the properties and the pictures as below:
You will notice that all the image fields have “Picture” in the name. I thought this way it easier to pick what fields to choose.
On the Dynamic page I created a Dataset called Properties and linked it to the Properties Collection:
I created the Gallery on the page and linked it to the Properties Item dataset with these settings:
From this Discussion I have taken the code that best suits my individual needs and modified it for the
getCurrentItem. In the code I replaced Dataset and Gallery names for mine and ‘Picture’ instead of ‘Image’ My Code is below with comments:
I have no idea what I have done wrong in the code. When previewing the page it doesn’t display anything, As if the gallery wasn’t there at all.
I’m sure with this info you have more of an idea what I am trying to accomplish. Could you review the code and advise me on where I went wrong.
Thanks, This is my very first post on the forum and from what I’ve heard and read you guys are great.
See the API for the imageItem . The key (src) should be in quotes. It should look something like this:
{"src": "source string"}
Before setting the items property, use a console.log() statement to see if imagesToShow has any content. It might be empty. Do something like this:
console.log(imagesToShow);
$w('#gallery1').items = imagesToShow;
If you continue to have problems, please post the URL of your site. Only authorized Wix personnel can get access to your site in the editor. Please include the name of the page involved.
You may also want to check out the WixArena - it’s a hub where you can look for Corvid (and other) experts for hire.