You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, November 9th 2011, 11:21am

variable syntax in url

Hi,

I can set variables in my xml file, except in <image> tag. I've searched in documentation and in the forum but I didn't find.

<scene name="scene3" onstart="action(startscene);">

Source code

1
2
3
4
5
6
7
8
9
10
11
12
<scene name="scene3" onstart="action(startscene);">

<action name="startscene">
set (var1,MyPanoName);
</action>

<preview type="CUBESTRIP" url="get(var1)/preview.jpg" />
<image>
	<cube url="get(var1)_%s.jpg"/>
</image>

</scene>


I've tried many ways, but is it ever allowed to use vars in url ?

Thanks for your help

Philippe

mindlessboss

Professional

Posts: 1,081

Location: Russia, Kaliningrad

  • Send private message

2

Wednesday, November 9th 2011, 12:40pm

Hi!
No way to use variables directly in attributes *mellow*
Sorry

Andrey
VRAP - desktop VR content player based on krpano.
Common tasks in one place in one click! Discussion thread
DOWNLOAD for MAC
DOWNLOAD for WIN

Zephyr

Professional

Posts: 994

Location: Netherlands

Occupation: Web developer

  • Send private message

3

Wednesday, November 9th 2011, 1:51pm

you could resort to php:

image.xml.php:

Source code

1
2
3
4
5
6
7
8
<?php
   $panoname = 'test';
?>
 
<preview type="CUBESTRIP" url="get(var1)/preview.jpg" />
<image>
	<cube url="<?php echo $panoname; ?>_%s.jpg"/>
</image>


or you could set the url through html addVariable

var panoname = 'test'; //or get it from url
viewer.addVariable('image.cube.url', panoname + '_%s.jpg');
3d childrens game using krpano Game
Minify your xml with my krpano XML Compressor
Krpano XML Parsing Error Checklist
Available for hire (krpano xml, javascript, actionscript, flash, php and ipad plugins).

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

4

Wednesday, November 9th 2011, 5:08pm

Hi Philippe,

Or following your approach, you can do:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
<scene name="scene3" onstart="action(startscene);">

	<action name="startscene">
		set(var1,MyPanoName);
		txtadd(preview.url,get(var1),/preview.jpg);
		txtadd(image.cubestrip.url,get(var1),_%s.jpg);
	</action>

	<preview type="CUBESTRIP" url="" />
	<image>
		<cube url=""/>
	</image>

Or similar:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
<scene name="scene3" onstart="startscene(MyPanoName);">

	<action name="startscene">
		txtadd(preview.url,%1,/preview.jpg);
		txtadd(image.cubestrip.url,%1,_%s.jpg);
	</action>

	<preview type="CUBESTRIP" url="" />
	<image>
		<cube url=""/>
	</image>

</scene>


SAlut.

5

Wednesday, November 9th 2011, 7:35pm

Hi

Thank you all for your responses.
I tried (the only script that shows something):

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
<scene name="scene3" onstart="startscene(Pano1);">

	<action name="startscene">
		txtadd(preview.url,%1,/preview.jpg);
		txtadd(image.cubestrip.url,%1,"/",%1,_%s.jpg);
	</action>

	<preview type="CUBESTRIP" url="" />
	<image>
		<cube url=""/>
	</image>

</scene>

Just added ,%1,"/" because files ares in a folder.
The preview works fine, but the image (which is in the same folder) doesn't load, even when I replace %s with:

Source code

1
2
3
4
5
6
	        txtadd(image.cubestrip.url,%1,"/",%1_l.jpg);
		txtadd(image.cubestrip.url,%1,"/",%1_f.jpg);
		txtadd(image.cubestrip.url,%1,"/",%1_r.jpg);
		txtadd(image.cubestrip.url,%1,"/",%1_b.jpg);
		txtadd(image.cubestrip.url,%1,"/",%1_u.jpg);
		txtadd(image.cubestrip.url,%1,"/",%1_d.jpg);

Strange. The error message says : ERROR: download of "pano1/pano1_%s.jpg" failed - in the first case - and nothing appears when naming images l f r b u d : only one image pano1_d loads but doesn't appear (I see it in Safari console only).
I can't see what is missing.

Thanks for your help

Philippe

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

6

Wednesday, November 9th 2011, 10:35pm

Hi Philippe,

In your code the image type is cube, not cubestrip ;-) ...
The code corrected:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
<scene name="scene3" onstart="startscene(Pano1);">

	<action name="startscene">
		txtadd(preview.url,%1,/preview.jpg);
		txtadd(image.cube.url,%1,/,%1,_%s.jpg);
	</action>

	<preview type="CUBESTRIP" url="" />
	<image>
		<cube url=""/>
	</image>

</scene>


SAlut.

7

Wednesday, November 9th 2011, 10:52pm

NICE ! you're right : I could never have found it.

Thanks you all !

Philippe

mindlessboss

Professional

Posts: 1,081

Location: Russia, Kaliningrad

  • Send private message

8

Thursday, November 10th 2011, 1:11am

Hi!
One more thing, this will work only if you change image and preview in onstart event.
This not work after. Another words you can't set url of image or preview by clicking some button or else way

Regards
Andrey
VRAP - desktop VR content player based on krpano.
Common tasks in one place in one click! Discussion thread
DOWNLOAD for MAC
DOWNLOAD for WIN

9

Thursday, November 10th 2011, 8:42am

Hi Andrey

Thanks for that clarification !

regards

Philippe

10

Friday, November 11th 2011, 1:38pm

Hi,

to be exact - there is a possibility to use variables inside urls - but only when these variables were defined BEFORE the current xml or scene was loaded - that means these variables must be defined/set either in the HTML file - or before a loadpano() or loadscene() call,

see here for details:
Questions about flash caching

best regards,
Klaus

Hellkeeper

Intermediate

Posts: 146

Location: St. Johann in Tirol

  • Send private message

11

Friday, April 28th 2017, 9:59pm

Hi,

to be exact - there is a possibility to use variables inside urls - but only when these variables were defined BEFORE the current xml or scene was loaded - that means these variables must be defined/set either in the HTML file - or before a loadpano() or loadscene() call,

see here for details:
Questions about flash caching

best regards,
Klaus


Klaus - is this still valid for HTML5 Player as well? As I would need to build Image Path with Variables ...
I try it like that:

<level tiledimagewidth="640" tiledimageheight="640">
<cube url="%$domain%/my/path/9/tiles/mres_%s/l1/%v/l1_%s_%v_%h.jpg" />
</level>

Any ideas on that?

thx
Andreas Schnederle-Wagner
Andreas Schnederle-Wagner
Rundblick GmbH / Gigapixel aus Österreich
https://www.rundblick.at/
https://www.gpix.at