I converted an Asset Tracker application template a bit into my own form. With this I want to test the tools and if it works well we will make a more detailed own application.
It has been pretty much redesigned for testing, but there would be two more details that I would like to solve, if not too complicated.
first I want to change the default image in the device list to a custom image for each device and add it from the file list.
Currently, all devices place the default image in the device list
device-list-image-container-be. I want to solve this where an image is assigned to the device instead of the default image.
Can anyone help me solve this? Where and how can I add an image to devices in the device list?
The current template should be redesigned, I just don’t know where to touch it.
I’m a beginner in Losant.
The proposed template could not be added to the application; it does not currently have the appropriate resources. I don’t want to go deep because it’s just a temporary test app.
There should be a simple solution that can be applied in the current template.
Add a tag to your devices - let’s call it “imagePath” - and set its value to the location of that device’s image in your application files. For example, to use the image that’s included in the template, you would set the value of that tag to “/asset-tracker.jpg”.
In this file you found, on line 28 (what you highlighted), change the src attribute to “{{file this.tags.imagePath}}”.
Save the file.
You’re just referencing a value on the device - the tag you added in the previous step - the same way you reference any other value on the device object, using that variable instead of the static value in the {{file}} helper.
The code looks right; did you add an “imagePath” tag? Did you set its value the way I mentioned in my last reply? Did you upload a file of that name at the path you specified in the tag value?
Viewing the source of the outputted HTML, what is actually being rendered for each list item’s <img src> attribute?
Your “imagePath” value isn’t following the format from my example; you have in there “file/default_red.png”. It should begin with a slash (/) and, assuming that file is located in the root directory (which I can’t tell from your screenshot), it should be “/default_red.png”.
i looked it up and read through the forum but couldn’t find an example of this tool image display.
I tried the Markdown function, but the image from the link didn’t work either. I need to display the device image from imagePath, as with img src.
Would you write a line of code for this?
Somehow I didn’t make it.
Hi Joe,
Were you ever able to add scaling to the image using Markdown? I have tried this, and can’t find any method/syntax that works.
Thanks - Stephen