I tried different solutions given here, here and here. But I get nothing to work, probably missing something small and simple.
I have this variable in a .js File:
var dziFilesUrl = 'http://localhost:3000/openseadragon/highres/{{ entry.kelimImageData }}/';
var dziData = '<?xml version="1.0" encoding="UTF-8"?><Image xmlns="http://schemas.microsoft.com/deepzoom/2008" Format="jpeg" Overlap="1" TileSize="254"><Size Height="5097" Width="3600"/></Image>';
where I want the entry.kelimImageData coming from the Backend.
In my .twig File i have this:
{% includeJsFile "/assets/js/openseadragon-custom-dzi.js" %}
{% set myJs %}
tileSourceFromData('{{entry.kelimImageData}}');
{% endset %}
{% includeJs myJs %}`
My openseadragon-custom-dzi.js File looks like this (modified to make it not so long)
var dziFilesUrl = 'http://localhost:3000/openseadragon/highres/{{ entry.kelimImageData }}/';
var dziData = '<?xml version="1.0" encoding="UTF-8"?><Image xmlns="http://schemas.microsoft.com/deepzoom/2008" Format="jpeg" Overlap="1" TileSize="254"><Size Height="5097" Width="3600"/></Image>';
var tileSourceFromData = function(data, filesUrl) {
var $xml = $($.parseXML(data));
var $image = $xml.find('Image');
var $size = $xml.find('Size');
var dzi = {
Image: {
xmlns: $image.attr('xmlns'),
Url: filesUrl,
Format: $image.attr('Format'),
Overlap: $image.attr('Overlap'),
TileSize: $image.attr('TileSize'),
Size: {
Height: $size.attr('Height'),
Width: $size.attr('Width')
}
}
return dzi;
};
}
var viewer = OpenSeadragon({
...
tileSources: tileSourceFromData(dziData, dziFilesUrl)
});
{%includeJsFile "" %}to{% js "" %}. But i get an error: "Uncaught SyntaxError: Invalid regular expression flags", which i cannot find. Between the "" in {% js "" %} i have to put the path to the js file, right? And what do you mean by "then remove the setting of those vars..."? Should i remove the vars in the .js File? – Henrik Dec 07 '19 at 08:41There's no longer any need for the
– Campiotti Dec 09 '19 at 09:25"/path/to/file.js"in{% js "" %}as it's been changed (see linked docs in updated answer), now you just do{% js %}I'll try and look around in the docs to see if I can find anything, not sure what could be causing this type of output currently.
I don't think it's an encoding issue though.
– Campiotti Dec 16 '19 at 06:51