I am trying to use Material UI's Avatar with images outside the website.
<Avatar
src={'http://localhost:3030/images/a/1651325908227-Capture.PNG'}
/>
If I try using an online source(not my local server) it seems ok:
<Avatar
src={'https://mui.com/static/images/cards/basement-beside-myself.jpeg'}
/>
Other images on the website load correctly from the same backend.
Related
I'm building a memory game in React et Next.js, I'm using the pokeapi to load pokemon data like pokemon name, image etc.
I want to preload images from the pokeapi but hide them in the DOM to avoid malicious users inspecting the HTML.
If I show the card conditionally like this:
{isSwitchedCard && (
<NextImage
src={card.image}
width={150}
height={150}
alt={card.name}
draggable={false}
className="m-5 rounded-t-lg"
/>
)}
the image load when the user click on it and it could take too much time for certain users with bad network.
So I search for a solution to preload images from API but hide them from the DOM, any ideas?
I am loading a React Native's WebView component like so:
<WebView
source={{uri: 'http://www.example-one.com'}}
onMessage = {(event) => console.log(event.nativeEvent.data)}
/>
And inside my www.example-one.com I add this javascript code
window.postMessage('It works!!');
This works great and I am able to the message from www.example-one.com in my React Native's console.
However, when I load the same WebView with same source and redirect the user to different source say www.example-two.com from inside wwww.example-one.com and add the javascript code inside www.example-two.com i.e.
window.postMessage('It works from example two!!');
then I don't see that message inside React Native's console.
Is there any work around to make this work?
I need to load on WebView a part of a webpage, like a div. is it possible?
for example
<WebView
source={{uri: 'https://www.amazon.com/'}}
style={{marginTop: 20}}
/>
with a div: id="nav-shop"
how to show only this part?
I think that the best thing to do is to 'hide' div elements, but i don't how to do that. If someone have some ideas tell me.
Webview has a parameter called injectJavascript where you can manipulate the javascript of the Webview you receive.
According to the documentation, you pass the javascript you want to run as a string.
https://facebook.github.io/react-native/docs/webview.html#injectjavascript
Ok so I'm trying to load images from external resources.
My web api returns a json to my Nativescript app.
In my Nativescript code, I parse a json retrieved from my api, to construct the view manually. Everything works fine but the image part.
For the image, I proceed this way:
var image = new imageModule.Image()
image.src = page.bindingContext.news.getItem(args.index).image_original_link
then I attach it to my layout, through addChild.
I also tried to do it through an XML template, and I have the same problem:
<Image src="https://www.google.com/images/errors/logo_sm_2.png" stretch="none" />
this --^ is never rendered.
If I replace the url by an image located in my local directory:
image.src = "~/images/foo.png"
Then it works perfectly.
I tried to replace the dynamic source url fetched from my array by a static link to an image and it's not getting accessed (I checked the log on the webserver serving said image).
What am I doing wrong?
edit:
I'm testing on iOS
I already have the following in my plist:
NSAppTransportSecurity
NSAllowsArbitraryLoads
Actually on iOS you need to set the height/width of the image control; try doing something like:
<Image src="https://www.google.com/images/errors/logo_sm_2.png" stretch="none" width="100" height="100"/>
In addition if you are using v2.30 of NativeScript there is a bug if you set any parents "color" it can propagate down to the image and cause the image to not show. To fix either remove the "color" from all parents or upgrade to the 2.4 (when released or #next until released)
I'm new to Photoshop scripting and javascript. How can I read via code the image inside the active window in Photoshop CS5-C6 and paste that image into a web page DIV?
FYI I'm a complete newbie to programming. My goal is to build a simple Mac App prototype with a wrapper running a web app inside. That web app needs to connect to Photoshop via TCP and read the image inside the selected window document and then paste it somehow into the web app's html. (Photoshop has feature inside the edit menu called 'remote connections' that converts Photoshop into a server and allows any external applications to read/write stuff inside Photoshop by sending javascript over TCP)
So, how can I:
1) Access Photoshop over TCP via javascript?
2) How can I get the image inside the active Photoshop window and paste into the web app?
I might need some additional information to help more accurately, but if I understand correctly I'd say you are running your code on your local machine.
Please post the development environment you are using (Visual Studio, eclipse, etc.)
First Approach
You will want to save you Photoshop image and add that file to your project. Just in case, I would recommend actually moving the image into your project folder first.
So, if you saved the image to "C:/Username/Pictures" - move it to "C:/Documents/Visual Studio 2010/Projects/MyWebPage"
Once you've done that, just add an IMG tag and the file path. If you moved the image into the project folder, the path should just be the filename:
<div>
<img src="myPhotoshopImage.gif" alt="Image">
</div>
You can put whatever you like inside the alt quotations (""), it doesn't effect the way it works. You can also specify the dimensions by adding height and width (this is optional) like so:
<div>
<img src="myPhotoshopImage.gif" alt="Image" height="260" width="420">
</div>
Second Approach
If you don't want to worry about managing your image files in your project, you can choose to host them online.
First, save your imagine in photoshop. Then choose an image hosting service. I would suggest ImageShack for an easy start. I would also suggest creating an account to keep track of everything.
Log in to ImageShack and go to the "Media Upload" tab. Click the "Browse" button and locate your image. Click OK. If you want your image to appear the same as it looks on your computer, make sure "Do Not Resize" is selected. Finally, click "Upload Now" & "Continue to Image Links" on the following page.
You will notice they have generated an HTML link for you already, which will work - but will also act as a link to ImageShack if clicked on. If you want to avoid that, just follow the same pattern:
<div>
<img src="http://img541.imageshack.us/img541/2232/123vm.jpg" alt="Image" height="260" width="420">
</div>
You'll need to do some research on any other actions you want the embedded image to take. A great place to start is W3Schools.
Edit - Forgot to mention... If you are wanting to use some javascript functions to work with the image, give your image an "id" attribute:
<img src="something.jpg" alt="whatever" id="headerImage">
You can now access the image via javascript:
function foo() {
var myImage = document.getElementById("headerImage");
myImage.height = 1000;
myImage.width = 832;
};
Also, if you are having any trouble, make sure your image is saved as a common filetype (not .psd)
There is a python wrapper for connecting to photoshop called photoshopConnection
One thing you can do is get the actual file info from PS and then copy the file itself into the webapp. I do not think the photoshop server supports streaming data in the fashion you are looking to.