These are chat archives for openseadragon/openseadragon

19th
Aug 2016
Stephen Crampton
@sacrampton_twitter
Aug 19 2016 07:17
I am a very poor programmer and am struggling to get the tileSources to accept a variable for url.
Chris Engberg
@chris-engberg
Aug 19 2016 07:18
I only know the basics, but can you post what you are doing?
Stephen Crampton
@sacrampton_twitter
Aug 19 2016 07:19
In my HTML I can enter <h3>Photograph URL: ${PHOTOGRAPH}</h3> and it will correctly display something like "Photograph URL: https//something. amazon.com/myphoto.jpg"
But when I use tileSources: {
type: 'image',
url: ${PHOTOGRAPH}} - it gets nothing in the url
Antoine Vandecreme
@avandecreme
Aug 19 2016 07:22
what is in charge of replacing ${PHOTOGRAPH}?
is it PHP, a JS framework... ?
Stephen Crampton
@sacrampton_twitter
Aug 19 2016 07:23
Hopefully that makes sense. My code works perfectly if I hard code it with url: "https://something.amazon.com/myphoto.jpg"
This is where my limitations come in - I'm generating this HTML for use with Amazon Mechanical Turk - in the Mechanical Turk environment you load a CSV file and that passes the rows of the CSV to this script
Antoine Vandecreme
@avandecreme
Aug 19 2016 07:26
@sacrampton_twitter your issue is probably not with OSD but on whatever framework you are using to replace ${PHOTOGRAPH} with the correct URL
Stephen Crampton
@sacrampton_twitter
Aug 19 2016 07:27
OK thank you
Ian Gilman
@iangilman
Aug 19 2016 16:29
@sacrampton_twitter can you look at the source that's produced after the replacement is done? That might give some clue. One thought that comes to mind is that you probably need to provide the quotes, like so: url: '${PHOTOGRAPH}'
(since the JavaScript will want it to be a string)
Stephen Crampton
@sacrampton_twitter
Aug 19 2016 23:23
Thanks for the input - I managed to solve this after a lot of messing around - I'm not a programmer, so no doubt this is an ugly solution - but it works and I share it in case anyone else is trying to generate some HTML to use with Amazon MTURK
I put the following input statement into the HTML - MTURK creates the variables ${PHOTOGRAPH} when it loads a CSV file.
<input Name="photo" value="${PHOTOGRAPH}" style="display: none;" type="text" style="display: none;">
Then in the javascipt I put the following
var photo = document.getElementsByName("photo");
Then in the openseadragon part of the code I put the following
tileSources: {
type: 'image',
url: photo[0].value} ,
And it all works
Ian Gilman
@iangilman
Aug 19 2016 23:28
Actually seems like a pretty clever solution :) Glad to hear you got it sorted out!