Get Image name onclick - spring

I am new to Spring boot and thymeleaf.
I wanted to know how I could get the name or id of an image onclick.
Any help or documentation would be appreciated.

Maybe you should try this one:
th:attr="onclick=|what you want to do|"
or you can use use the tag inside th:each:
<img th:src="#{'/photos/' + ${yourimage.image}}"/>
depending on what you want to do.
And as long as you asked for documentation, check this out about attributes:
https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#setting-value-to-specific-attributes

Related

Google Analytics Event Image Tag Creation

Wondering if someone can help me...
I'm working with an application system that only accepts simple img tags for tracking, they won't take JS or GTM at all.
Is it possible to create these for events, so I can create the necessary goals within Google Analytics?
I have the event like so:
ga('send','event', 'ATS','Application', 'Application Start',0,{'nonInteration':false});
But obviously I need the img part and the UA-ID etc. I'm not great with this stuff and all the documentation I can find relates to email sends, which isn't applicable here.
Also, it's for a page load.
Many thanks for any help!
Tom
yes, you can build up your simple image tag using Measurement Protocol. You can use handy Hit builder tool to populate a necessary event url
For those reading in the future... This is what ended up working:
<img style = "width: 1%; ; "src="https://www.google-analytics.com/collect?v=1&t=event&tid=UA-XXXXXXXX-1&cid=555&ec=ATS&ea=Application&el=Application%20Start&ni=0"alt=""height="1"/>
I used the hit builder mentioned above: https://ga-dev-tools.appspot.com/hit-builder/ (thanks Дмитро Булах) to determine which parameters I needed and added the collect query to tell them to be sent to GA.
I put the cid as 555 to anonymise it (don't know if that was a good idea), then put the whole thing inside an img tag I lifted from somewhere else.
Cheers,
Tom

Node-red create dynamic hyperlink on Dashboard

I want to create a dynamic hyperlink on the dashboard in any way. I am reading a part of the URL from a textfile which works so far. Only the last part beyond the / shold be dynamic.
The URL should look like https://example.webpage.com/"dynamic part"
I am using the ui-template node.
I think this post will help you!

MVC Razor use ViewBag as part of dynamic Image link

I've got an MVC Application and I've got a ViewBag List of Items. I've got the List using Razor to show in a Modal popup and I was hoping to use said list, to dynamically display an image for each item in the list
I'm hoping for something along the lines of "~/Images/ + #ViewBag.List[i] + .jpg"
Does anyone know of a way to achieve this as I've not had much luck so far?
Any assistance on accomplishing this would be greatly appreciated!
Thanks in advance
Paul
#foreach(var item in ViewBag.List)
{
<img src="~/images/#(item).jpg" />
}
Should work for you. The issue you were running into is you do not need the:
+ #ViewBag.List[i] +
#ViewBag.List[i] will work inline without any string concatenation.
The answer to the question you asked:
#foreach(string image in ViewBag.List)
{
<img src="~/Images/#(image).jpg" />
}
But really you should be putting this into your model (not the ViewBag) and doing something similar where you iterate over the list in your model. Additionally, List is a horrible name for a list of images. You should maybe name that images instead.

Upload file using input tag(without rails/html form) and paperclip in rails

I am a kind of new on ROR, I want to upload an image using simple input tag and don't want to use form for that. The basic functionality of Paperclip is known to me. If I am not wrong then the format of object that is being passed to save image is :
"image_object"=>
[#< ActionDispatch::Http::UploadedFile:0xb5ad25f4
#content_type="image/gif",
#headers=
"Content-Disposition: form-data; name=\"pic[]\"; filename=\"test.gif\"\r\nContent-Type: image/gif\r\n",
#original_filename="test.gif",
#tempfile=#<File:/tmp/RackMultipart20131112-17750-1lprijc>>]
I want to upload image using the following steps:
1. Using Jquery, I want to fetch the appropriate details(file parameter) of selected image in input tag and send those using Jquery/ajax.
2. By passing that parameters to rails controller I want to use those details to generate an object(as sample shown above) that can be used to save Image in my application.
My questions are:
1. which Jquery method should I use and what are the parameters that are necessary to generate the image object?
2. On controller side, how to generate Image Object using those details?
Thanks in advance.
I'm not sure if I understood your question right. But based on the details you provided there are many options you can go for.
The simplest one is as follows:
Just add :remote => true to the rails form and submit the form and on the controller side you can create the object.
But if you want to be able to upload an image through a REST API then this link should help.
You can visit the SO question as well here which describes exactly what u want.

How to write an mvc chart into a view

First, I've already tried showing a graph using a FileContentResult and the write method. But I can't use both since my requirement requires me to show a grid on 1 tab and a graph on the next tab. So I need to store the graph in a ViewBag and render it to a view, but I'm unable to do that. Is there anyway around?
Note: I'm using the Chart object from System.Web.Helpers namespace.
Thanks,
czetsuya
You can render chart as partial view.
you can use System.Web.Helpers namespace here an example:
http://msdn.microsoft.com/en-us/library/system.web.helpers.chart(v=vs.99).aspx
A chart is just an image. Link to it.
<img src="#Html.Action("ImageAction")" alt="Chart" />
I found a solution (without executing the same query), I stored the image in a cache and later refer to it via a unique key. Unfortunately, I needed to issue another http request for it. See post here: http://czetsuya-tech.blogspot.com/2012/02/how-to-render-chart-object-in-view-in.html

Resources