how to replace space in image url in nodejs - node.js

I am fetching data from an api and it contains image urls. When i try to display the images it is not showing any picture. when i logged using console.log(service.coverImage), i was able to display the image urls. for example
https://s3.eu-west-2.amazonaws.com/ererf3wery/Hillside Plaza Hotel 5cdebeaf34157a0026526f0d/providerImage/hph.jpeg
You notice the link breaks and it doesn't go to the image directly, now i cannot change this in the database. How can i solve this in Nodejs to replace the places so that it becomes complete.
I have used methods like replace and encodeURIComponent but not helping
thank you in advance

The image url looks fine, if you are not able to see the image in web page, try to remove protocol from it.
url = url.replace("https:", "");
If that doesn't work, then try removing spaces as you wanted:
let url = "https://s3.eu-west-2.amazonaws.com/ererf3wery/Hillside Plaza Hotel-5cdebeaf34157a0026526f0d/providerImage/hph.jpeg";
url = url.replace(/\ /g, "%20");
console.log(url)

Related

Fabric canvas text to read html tag

I am trying to make a image editor like yourquote.
I am using fabric js for editor.
I am doing it on website not app.
I have used 2 different url. On first url I want user to enter text and on second url I am letting the user decorate the text and make it image.
My regular text is working as I am posting the text to url, but when I am maintaining line break it is not working.
How can it be possible ?
Its solved
I added '\n' after each line break and sent the final string to next URL and the fabric js canvas loaded exact what I wanted.

How to represent a part of a string as an image in HTML?

I am working on a personal project in which I am using Magic the Gathering's API to search through their card databases and display them on my website. One of the problems I have encountered is that an argument of the card object that is stored in the database is displayed as {G},{R},{B},{U},{W} etc. but I want it to be displayed as one of the many images found here:
https://media-dominaria.cursecdn.com/attachments/132/91/635465459096129102.png
Considering that the argument is a string, I don't know how to replace the content of the string that is inside the curly brackets with a html image element and have it display properly in the browser.
For example:
mana_cost= "{G}{W}"
I would like to be able to show "{G}" as:
http://img2.wikia.nocookie.net/__cb20130604114032/mtg/images/f/f7/Mana_G.png
and "{W}" as:
https://static.giantbomb.com/uploads/original/8/88760/2277116-white_mana.png
Any help is welcome
You can use a RegEx on the client side and replace with the image before showing in the browser.
let strToReplace = '{G}';
strToReplace = strToReplace.replace(/{G}/, '<img src="http://img2.wikia.nocookie.net/__cb20130604114032/mtg/images/f/f7/Mana_G.png">');
I would download the image and put it on a local folder so you can replace for something like:
strToReplace = strToReplace.replace(/{G}/, '<img src="/images/Mana_G.png">');
fiddle: https://jsfiddle.net/649y20s3/

Send path of SDWebImage stored image to a UIWebView

I need to be able to get a path to images that cached.
While I am wondering if there is a way to do this using SDWebImage, I could probably get away with just having the knowledge to return a path to an image stored in the cache so I can display it within a uiwebview inside an image tag.
According to this https://github.com/rs/SDWebImage/issues/25 it would seem you can simply refer to the image by it's original url and it will be correctly picked up from cache.

Display image in a packagedapp/extension after selecting from Google Drive

My packaged app gets images from google drive and then display them on the side. But I can't get the images to be displayed. I am trying to get the url of the image so that I can put that url in an image source. The image url that I am getting is actually an html page rather than jpeg, png etc. I have looked at the reference guide for google picker but nothing seems to work.
I am using this
function pickerCallback(data) {
if (data.action == google.picker.Action.PICKED) {
var fileId = data.docs[0].id;
fileName = data.docs[0].name;
imgURL = data.docs[0].url;
}
I want to use imgURL as the source for image selection but imgURL is not something like "https//:www.example.com/image.jpg. It is rather an html page I want something that ends with file type only then it will be able to display the image. Please let me know how can I get the image to be displayed in html page of my packaged app after selecting it from google drive.
You should fetch the metadata of the image, then use the webContentLink of the image, then the user can view it in a logged in browser. See the documentation on downloads for more information.

Construct the url to fetch a page by url

With this code I create a page in a Google site:
pageEntry = new WebPageEntry();
pageEntry.setTitle(new PlainTextConstruct(PageTitle));
..
..
client.insert(new URL(getContentFeedUrl()), pageEntry);
If the PageTitle contains something like "création" the page will created with the name https://sites.google.com/.../.../cration. So "création" is changed to "cration".
Is the process to change the page name available in the API? I would like to fetch the page by its path, but the only key I have is "création".
Maybe a better solution would be to strip the diacritics from the characters in the string before setting it as a page title? For instance, see the javascript function here. Then you page would be created with the URL /creation, which could be more desireable.

Resources