To be honest, I don’t really understand what you want to achieve. If you want to see the source image for the scene, we can do this by displaying this information in some additional field using js. I can do an example of this.
Thank for your Quick reply :).
note: writing from my Phone, so autocorrect messing spejling up 🤣
i have a tour of an festival arena where i am voluntere, i have a tour where nothing are placed in the are.
And i have a tour where everything are placed.
by having the option to Go on the “clean” tour, i Can see the whole are, and by clicking the “button” i could see the same scene, where everything are placed. (Like a befor and after image)
so if i Can get the name of the image in currrent scene, i have a Way to generator the buttom for the scene in the “scene where everything is placed. By checking my “befor”folder and see if there is an image with the same name (if so, i also have a scene for it). And i would get the current sceneid of the current scene. Generate a link for my buttom where i just shangingchanging the item/tour id, that Will then show the other tour with the sceneid.
does it make more sense ? 🙂
Do you have to do this “automatically” with code? It seems you could just make the first scene in the tour “Before” and then the second scene “After”. It will create a button in the navigation menu to go back and forth?
Or I believe you can even do it with a “Hotspot” linking to the other scene.
Why must you create a new button?
Yes. It need to be code, instead of a hotspot.
a hotspot need to be made manual in all scene.
And if I use the solution to shift between scene, Old, new, Old new, i Will be confusing.
By coding it. The button wil be showed, if there is an image match in the “old” folder, and get the current sceneid, and make a link to the other tour and sceneid.. If not, the button will be hidden. All this will be automatic , so I don’t have to make a hotspot for each scene.
if I had the option for getting the needed information, I would have been done already. I already did it with som external custom_fields just to se if work :).
but I don’t know how to call the data from the scene.
This is an example of the code I have now. There are probably better ways 🙂 but this I teste, and working when I am using existing data for test:
// CHECK IF IMAGE EXISTS
function checkIfImageExists(url, callback) {
const img = new Image();
img.src = url;
if (img.complete) {
callback(true);
} else {
img.onload = () => {
callback(true);
};
img.onerror = () => {
callback(false);
};
}
}
// Get current image name from this view/scene.
$my_current_image_name = get_field('get_current_image_name');
// Check If folder with old image exist, and have an image with the same name.
checkIfImageExists('old_image_folder/<?php echo esc_url( $my_current_image_name ); ?>', (exists) => {
// If existing // Success code
if (exists) {
// Make field by using current sceneid, that show “old” tour.
$link_to_old_sceneid = "[id=2” sceneid=“$sceneid_from_current_scene]”; ?>";
const plugin = this;
const $ = jQuery;
// Get the CCS for Susses button, and insert link by echo the field $link_to_old_image into the href
const $btn = $('<a>').addClass('MyImgLinkOtherSceneYES').attr({'href':'<?php echo esc_url( $link_to_old_sceneid ); ?>','target':'_self'});
plugin.$container.append($btn);
}
// if NOT existing
else
{
// Fail code
const plugin = this;
const $ = jQuery;
// Get the CCS for MyImgLinkOtherSceneNO button, and make link
const $btn = $('<a>').addClass('MyImgLinkOtherSceneNO').attr({'href':'#','target':'_self'});
plugin.$container.append($btn);
}
});
Let’s go step by step. If we want to get the scene image src, we can use this code
const plugin = this;
const $ = jQuery;
plugin.$container.on('ipanorama:scene-show-complete', (e, data) => {
console.log(data.scene.cfg.image);
});
Below is the list with plugin events we can handle
Event Name Handler
ipanorama:scene-camera-start f(e, {scene})
ipanorama:scene-camera-change f(e, {scene})
ipanorama:scene-camera-end f(e, {scene})
ipanorama:scene-before-load f(e, {scene})
ipanorama:scene-after-load f(e, {scene})
ipanorama:scene-progress f(e, {scene, progress})
ipanorama:scene-error f(e, {scene})
ipanorama:scene-show-start f(e, {scene})
ipanorama:scene-show-complete f(e, {scene})
ipanorama:scene-hide-start f(e, {scene})
ipanorama:scene-hide-complete f(e, {scene})
ipanorama:set-scene f(e, {sceneId})
ipanorama:next-scene f(e)
ipanorama:mode f(e, {mode})
ipanorama:ready f(e)
ipanorama:fullscreen f(e)
ipanorama:popover-show f(e, {marker})
ipanorama:popover-hide f(e, {marker})
ipanorama:tooltip-show f(e, {marker})
ipanorama:tooltip-hide f(e, {marker})
-
This reply was modified 2 years, 8 months ago by
Avirtum.
Great 🙂 allots of option. But I have newer worked with this type of coding 🙈.
how do I:
- get the image name (the name will be what I comparing with, to se if I need to get the sceneid and have the button feature.
- getting the sceneid
- “passing” the image name to a $imagename_that_i_can_use_as_Field
- “passing” the sceneid to a $Seceneid_that_i_can_use_as_Field
Again, thank for your great support and willingness to help with all these special wishes and request 🙂
This code below is for 1,2, but I do not understan about 3,4
const plugin = this;
const $ = jQuery;
plugin.$container.on('ipanorama:scene-show-complete', (e, data) => {
const image = data.scene.cfg.image.split('/').pop();
const sceneId = data.scene.cfg.id;
const sceneTitle = data.scene.cfg.title;
console.log(image);
console.log(sceneId);
console.log(sceneTitle);
});
3 and 4 :
I don’t know how to “convert” it to a custom field, that I can use.
can I do it like this ?:
$now_i_got_a_imagename_field_i_can_use = console.log(image);
$now_i_got_a_sceneid_field_i_can_use = console.log(sceneId);
The problem is that I don’t see your code in its fully, so it’s hard for me to evaluate and understand it.
Im not shure how to do it otherwise 😅.
But I will try again 😎.
how to get name of the image, used in a scene, an make a $display_image_name output with that name.
also
how to get name of the sceneid, used, an make a $display_sceneid_name output with that sceneid.
by doing this, I could do this:
echo ‘<h3>this is the name of the image:’ . $display_image_field'<h3>’;
echo ‘<h3>This is the name of the sceneid:’ . $display_sceneid_field'<h3>’;
Maybe better to write me to email ) I kind of showed you how to get the name of the scene image file and the scene ID.
I figured it out 😅. I never use “simple” descriptions as image, as it can (collide) with other fields :). So I thought the should “convertes” to a field first.
everything is work as it should . And I am almost done 😎. Just need to make it more simple to understand for other (inc. my self) 🤣.