fixed displaying photo
This commit is contained in:
parent
7ad20993d9
commit
23ae8e1b1d
@ -86,7 +86,7 @@ $(document).ready(function () {
|
|||||||
const selectorContainer = $("#photoSelectorContainer"); // A div to hold the photo selector
|
const selectorContainer = $("#photoSelectorContainer"); // A div to hold the photo selector
|
||||||
selectorContainer.empty(); // Clear any previous options
|
selectorContainer.empty(); // Clear any previous options
|
||||||
|
|
||||||
// Create a dropdown or buttons to select a photo
|
// Create a dropdown
|
||||||
const selector = $('<select id="photoSelector"></select>');
|
const selector = $('<select id="photoSelector"></select>');
|
||||||
photos.forEach((photo, index) => {
|
photos.forEach((photo, index) => {
|
||||||
const option = $('<option></option>').val(photo).text(`Photo ${index + 1}`);
|
const option = $('<option></option>').val(photo).text(`Photo ${index + 1}`);
|
||||||
@ -99,9 +99,16 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
selectorContainer.append(selector);
|
selectorContainer.append(selector);
|
||||||
selectorContainer.show(); // Make sure the selector is visible
|
selectorContainer.show();
|
||||||
|
|
||||||
|
// 👉 Load first photo by default
|
||||||
|
if (photos.length > 0) {
|
||||||
|
selector.val(photos[0]); // set the first option selected
|
||||||
|
loadSinglePhoto(photos[0]); // actually load it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function loadSinglePhoto(photoPath) {
|
function loadSinglePhoto(photoPath) {
|
||||||
const img = $("#samplePhoto");
|
const img = $("#samplePhoto");
|
||||||
img.attr("src", photoPath);
|
img.attr("src", photoPath);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user