Drupal 8 JSON API : Convert relative url to absolute url - drupal

I am using json api to fetch my sites content. The body field in the article contains some images which when fetched using json api returns image path in relative format (eg : sites/default/files/08-2016/abcd.png). But I want this images path in absolute format (eg : http://www.mywebsite.com/sites/default/files/s/08-2016/abcd.png).

Related

Having trouble Embedding a specific Vimeo Url

I used to embed Vimeo videos with this url format: https://vimeo.com/514607003 (only numbers). It works just fine. But some videos are in an other format and I cant embed them no matter what:
https://vimeo.com/605783608/493d2ee578
I'm getting this error on console when I try to embed it:
GET https://player.vimeo.com/video/605783608 404 (Not Found)
when I add the second Id of the video Url to the embedded Url, the error remains the same.
The answer appears to be to embed the video with a special query parameter h containing the second key:
https://player.vimeo.com/video/605783608?h=493d2ee578
This is determined by looking at Vimeo's own embed code; I did not find documentation explaining why this is.

Including here.com static image

After adding static here.com map image into my HTML and converting to PDF got this error:
Uncaught Mpdf\MpdfImageException: Error parsing image file - image
type not recognized, and not supported by GD imagecreate
There is no problem regarding showing image in browser.
My link: https://image.maps.api.here.com/mia/1.6/mapview?app_id={MY_APP_ID}&app_code={MY_APP_CODE}&lat=52.518752&lon=13.402277&vt=0&z=14
If I use Google Map API for static image map convert to PDF works fine.
https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&key={MY_API_KEY}
UPDATE:
PHP Version 7.0.31 and GD version

Get TinyMCE 4.3 Image Tools to save images as regular image files

The new TinyMCE 4.3 Image Tools (eg when cropping) saves images as blob data instead of image files in a directory. the edited mage url is like
blob:http://www.example.com/f2953aa1-e64f-49e1-a6e3-a283986663bf
I want to upload the image file to a specific folder and then use it as regular image referance / path.
Note
The question I am going to put is similar to Image edit issue. but the answer to this question is not working. I also tried http://archive.tinymce.com/forum/viewtopic.php?id=35740 solution but not working because it produces always same name image name.
The basic process is that TinyMCE will create a separate HTTP POST for each image that you modify with the image editor. It will send that image to a URL of your choosing (via HTTP POST) based on the setting of the images_upload_url option in your init.
The image handler at the URL referenced in the images_upload_url (which you have to create) has to do whatever needs to be done to "store" the image in your application. That could mean something like:
Store the item in a folder on your web server
Store the item in a database
Store the item in an asset management system
...regardless of where you choose to store the image your image handler needs to return a single line of JSON telling TinyMCE the new location of the image. As referenced in the TinyMCE documentation this might look like:
{ location : '/uploaded/image/path/image.png' }
TinyMCE will then update the image's src attribute to the value you return. If you use the images_upload_base_path setting in the init that will be prepended to the returned location. The TinyMCE page has more details on all of this:
https://www.tinymce.com/docs/advanced/handle-async-image-uploads/
The net here is that TinyMCE knows when an embedded image exists in your content but it can't possibly know what to do with that image in the context of your application so that job (the "image handler") is something you must create.

Generate thumbnail from remote jpeg without downloading

I want to load the EXIF thumbnail preview stored in a jpeg image located on a remote server, without having to download the whole image. The server does not support resuming.
Is this possible? In detail, can I assume that the thumbnail image data is alway before the full image data so that I only have to download a maximum of (e.g.) 100kb which I can parse for the thumbnail data?
I was asking the same question and found this Greasemonkey script which adds thumbnail images to an Apache auto index page.
https://userscripts.org/scripts/review/5390
For each JPEG image link it issues a range request for the jpeg / jfif header, parses the thumbnail offset and thumbnail length tag then issues a further range request for the thumbnail, creates a data uri and assigns it to a new img object.
Unfortunately it only works for certain JPEG file formats.

ASP.NET Image control not displaying an image

I am trying to display an image from "C:\temp". Here's the code:
string root = "C:\temp\";
string[] files = Directory.GetFiles(root);
foreach (string f in files)
{
if (Path.GetFileName(f).Contains(user.WorkEmail))
{
img1.ImageUrl = root + Path.GetFileName(f);
}
}
If an image is not found, I get a thumbnail with a red "X" - fine, as expected.
If an image is found, I get a thumbnail but no image gets loaded/displayed. When I right click the thumbnail and go 'Properties' it shows the correct filename.
You need to make this image part of the web site in order to display it properly. You need to use a relative URL:
img1.ImageUrl = '/App_Data/foo.jpg';
The image file cannot be located anywhere, when it is part of the web site a separate request is made to the server to fetch the image which is served by IIS. If you want to use image files located in a folder outside of your site root you will need to write a generic handler which will read the image contents, stream it to the response with correct content-type and then point the ImageUrl to this handler.
looks like you're creating strings of the form "C:\temp\myfile.jpg", right?
That's not a valid URL. your address needs to be either relative to your website's root (e.g. /content/myfile.jpg) or else it needs to include the protocol (e.g. file://c:\temp\myfile.jpg for local files or http://mysite.com/content/myfile.jpg for web access)
i had that problem and solved it ...
you should give the image adres cut
e.g:
www.yoursite.com/folder/image.jpg
Your image source should be = "folder/image.jpd"
No need of root or website.

Resources