I have (java) code that generates PNG images from a custom infrared camera from time to time all the same size and, at the moment, just saves them outside the server space. They all have the same name and the most recent overwrites the previous one.
I can send a message to my dart code in the browser that an image is available for automatic loading for display in an image element.
Should I create an image folder and save them there?
How would the browser request and display the image? I'm using port 4955 for html.
I'm new at dart, html etc.
<-- edit -->
Will this allow me to change the DOM?
HTML
<div id='image-div'>
<img alt='' id='image' src='resources/200C-B12.png'
height='480' width='640'>
</div>
CSS
#image {
}
Dart
ImageElement imageElement = querySelector('#image');
I think I want to change the above ImageElement to this the below but don't know how.
"<img alt='' id='image' src='imageDisplay/myimage.png'
height='480' width='640'>";
<-- edit -->
I have tried the suggested methods to request the image but none works. The most recent attempt is below. I have a statement that writes to a log-file in the Dart server code that handles HTTP requests and, while there are log entries made when the page page is loaded there are none when I try to request a different image. The client page does receive the correct path to the image so the problem is that I still don't grok the correct procedure.
HTML currently - want to replace src ... to src='displayImage/some_image.png'
<div id='img-box'>
<div id='image-div'>
<div id='imgAnchor'>
<img alt='' id='image' src='resources/fi_12_demo.png'
height='480' width='640'>
</div>
</div>
</div>
Dart code fragment:
void displayNewImage(imagename) {
updateLog('display image = $imagename'); // imagename is correct
var anchor = querySelector('#imgAnchor');
anchor.children.clear;
anchor.append(new ImageElement()
..innerHtml="<img alt='' id='image' src='$imagename' height='480px' width='640px'>");
}
I conclude that no request is being sent from the client to my Dart server.
I think adding an <img src="http://yourserver.yourdomain.com:4955/somefolder/someimg.png"> to your HTML dynamically (by Dart code) should do. If the updated images have the same name you might run into caching issues (the browser doesn't load the image from the server but loades it from the cache instead). It might be easier to store each image with a new name.
Related
In my Umbraco 7.15.7 I'm displaying images in the Partial Views Macro Files as follow:
figure>
#if (newsItem.HasValue("articleImg"))
{
<img src="#Umbraco.Media(newsItem.articleImg.ToString()).Url" class="img-fluid news-img" alt="#newsItem.Last().photoAlt" />
}
(the reason for the .ToString() is after I switched from Obsolete to Media.Picker2 - so since it's string)
In my Umbraco 11.1 I was struggle to display the images. I tried the following and it didn't display the images, but also didn't throw an error, just didn't display the images:
<img src="#Umbraco.Media(newsItem.Value<IPublishedContent>("articleImg").ToString()).Url()" class="img-fluid" alt="#Imaging_pagesToList.Last().Value("photoAlt")" />
So I tried this one:
<img src="newsItem.Value<IPublishedContent>("articleImg").Url()" class="img-fluid" alt="#newsItem.Value("photoAlt")" />
And this one also doesn't show any image
I also tried this one (the same as above, just with # - #newsItem) , and this throw an error: "Argument 3: cannot convert from 'method group' to 'object?'":
<img src="#newsItem.Value<IPublishedContent>("articleImg").Url()" class="img-fluid" alt="#newsItem.Value("photoAlt")" />
So I tried this one:
var image = newsItem.Value<IPublishedContent>("articleImg");
<img src="#image.Url()" class="img-fluid" alt="#newsItem.Value("photoAlt")" />
And this is finally works! And I don't understand why? (why this works, and why the previous didn't work)
My question are:
Why only the last one works?
Why the first two doesn't work?
Is this is the right way to render images in Umbraco 11.1 ?
In the official documentations of Umbraco (9 and up) they suggest to render images as follow:
var mediaItem = Umbraco.Media(Guid.Parse("55240594-b265-4fc2-b1c1-feffc5cf9571"));
But they hard coding the Guid in their examples.
Not sure how to get the Guid for each node.
Please advise.
Thanks.
Please check what property editor is used; maybe it's a collection and not a single media. In that case, you will need something like:
newsItem.Value<IEnumarable<IPublishedContent>>("articleImg").First().Url()
I'm trying to use data-interchange from Foundation 5 with slim as follows:
= image_tag('', 'data-interchange' => "[#{image_path('umed-image-large.jpg')}, (medium)], [#{image_path('umed-image-small.jpg')}, (small-only)]")
The problem is that it works the first time when loading the page but when clicking on a logo in the nav bar (the url is the same), the image is no more displaed. I observed the generated HTML in the Chrome console when the image is displayed:
<img data-interchange="[/assets/umed-image-large-45e4ffd1823f658bf167972ba4a8cad74797963d9a8906f65a8710d1c7458145.jpg, (medium)], [/assets/umed-image-small-97b7dfa3c6ca88e76b355eece97b723f458ae455f501013d1b0084ce0f5bd953.jpg, (small-only)]" src="/assets/umed-image-large-45e4ffd1823f658bf167972ba4a8cad74797963d9a8906f65a8710d1c7458145.jpg" data-uuid="interchange-j30j01nh0">
And here is the HTML when there is no image:
<img data-interchange="[/assets/umed-image-large-45e4ffd1823f658bf167972ba4a8cad74797963d9a8906f65a8710d1c7458145.jpg, (medium)], [/assets/umed-image-small-97b7dfa3c6ca88e76b355eece97b723f458ae455f501013d1b0084ce0f5bd953.jpg, (small-only)]" src="">
As you see, there is no src data in the latter case. Any idea what is wrong here ? Thank you.
When you insert an image into a TWebBrowser in edit mode, how do you get the filepath of the inserted image? When an image is inserted it includes the full path to the image in the html source, but in my case I need to modify the html source to only include the filename.
EDIT:
This is the html source after the image is inserted:
<IMG border=0 hspace=0 alt=delphi align=baseline
src="C:\Images\delphi.bmp">
I need to change
<IMG border=0 hspace=0 alt=delphi align=baseline
src="C:\Images\delphi.bmp">
to
<IMG border=0 hspace=0 alt=delphi align=baseline
src="HTML\delphi.bmp">
Yes I can get the path from the html but I'd like to try to copy the image file to the HTML folder then change the path to the HTML folder after the image is inserted without parsing the html. If the filepath can be obtained after the image is inserted I can add the code to copy the file to the HTML folder so that the image appears in the webbrowser with the new path...
Have you tried using the browser's DOM interfaces to read the src attribute and update it to what you want? Specifically, look at the src property of the IHTMLImgElement interface.
i need links in a profile-tab app i'm writing open in new browser tabs. i set target="_blank" (with both hardcoded and with FBJS), but when i click on the links, the app page just reloads. i had a look at the html of the app as it's rendered by FB, and each of my links has an onclik event on it, that after creating a new image, returns false.
i tried doing linkDomObjectHandle.purgeEventListeners('click'), but as i expected, that didn't do much.
does anyone know of a way to get this to work?
edit: tested, and "right-click -> open in new tab" and middle-click both do what is expected. just the left click event gets hijacked.
edit:
some code snippets:
i have a template that is cloned, filled and the clone is appended to an element. here is the html of the template:
<div id="hover_window">
<a href="">
<img src="">
<div class="article_info">
<div class="client_info"></div>
<div class="media_info"></div>
</div>
</a>
</div>
i fill the link by doing:
var hover_window = document.getElementById('hover_window').cloneNode(true);
hover_window.setClassName('active_hover_window');
hover_window.getFirstChild().setHref(targetLink.getHref());
i tried adding both target="_blank" to the html and .setTarget("_blank") to the FBJS, to no avail.
pls advise.
This works in my facebook profile tab-app
Link targetting _blank for me
Link test
Facebook edits this link and adds "target" depending on the href-url specified. If it is an internal facebook target, it targets the current frame, if it is and external url, it targets blank. Please just try the link above and see if it works for you (and remove all that javascript and stuff you have)
I'm using ASP.NET MVC and have a model which has an image (byte array) in one of the fields. I'm trying to output this image into the src attribute of the img tag. I'm looking to do something like <img src='<%= Model.VenueImage %>'>. How can I do this?
Maybe Inline Images with Data URLs idea?
Inline images use the data URI scheme
to embed images directly within web
pages. As defined by RFC 2397, data
URIs are designed to embed small data
items as "immediate" data, as if they
were referenced externally. Using
inline images saves HTTP requests over
externally referenced objects.
System.Drawing.Image image = GetImageFromSomewhere(...);
byte[] imageData = ImageToByteArray(image);
string imageBase64 = Convert.ToBase64String(imageData);
string imageSrc = string.Format("data:image/gif;base64,{0}", imageBase64);
and then somewhere in the page:
<img src= "<%= ImageSrcBytes %>" />
AFAIK this will work for Opera 7.2+, Firefox, Safari, Netscape, Mozilla and IE8+ (IE8 up to 32kb).
For earlier version of IE there is a workaround - MHTML.
The example how to do it is here.
The browser uses the src attribute to issue a separate request to the server, to get the contents of the image. It does not display the bytes in the src as the image itself.
So you will need to remember those bytes (session?) and use a handler (the url you put into the src attribute) to let the browser request them.