In TinyMCE is there a feature to allow pasting images when using the backend image load handler which saves uploaded images on the server? - tinymce

I'm using the image upload script with a backend URL to rename uploaded images stored on the server. It seems to work well with both file uploads and also drag-and-drop.
Without that backend handling you can paste images directly into the editor, but they get saved as base64 with the post in the db itself which is not great for a lot of reasons.
If I use the image upload script as I am now, it seems it blocks the pasting of images directly into the editor. That's safest, I guess, but I was wondering if there was a way of allowing it, but treating the pasted image like a drag-and-drop image, for example, so we could have the convenience of pasting images but still have them saved with unique filenames on the server instead of being embedded as base64 with the rest of the source of the post?
Thanks.

Related

Why does the TinyMCE server-side handler example in PHP include a file extension check if you can't select a non-image anyway?

Interesting.
I wanted to add logic to catch the upload of non-images. In the PHP example in the docs, they had this:
// Verify extension
if (!in_array(strtolower(pathinfo($temp['name'], PATHINFO_EXTENSION)), array("gif", "jpg", "png"))) {
header("HTTP/1.1 400 Invalid extension.");
return;
}
So I added something like that to my server's backside server-side JavaScript.
But it turned out not to be necessary. The image upload dialogs (either browse or drag-and-drop) somehow don't let you select anything but images.
If that's so, why does the example add that to the handler?
There are a couple of reasons but I'll stick to the main 2:
You may not want to accept all image types, perhaps you don't want users to upload .gif files because it will be ugly to see gif images in content, or perhaps your server doesn't support this type of image.
Using terminal commands like curl or GUI applications like Postman, you can skip the normal browser upload workflow and upload whatever you like to the server. Highly dangerous as users could upload anything if you don't perform some sort of validation, they could upload a .php file for example and cause all sorts of havoc.

Image Thumbnails in wysiwyg editor

Is there a way to have directus insert links to thumbnails instead of the original full-size image when using the wysiwyg editor?
Context:
We have directus configured to use S3 for file uploads. Our backend directly connects to the directus db to fetch data and return it to the client in whichever form it is needed.
Now for the wysiwyg editor all html it generates is fine. However, images inserted with it always link to the original image.
In our case the client is a mobile app. Saving bandwidth with thumbnails is important because the app is used a lot without wifi.
I'd like to avoid having to parse the src tag and replace it with a different link. Mainly because it is not a simple search and replace, as the link contains the location on s3 (uuid), not the id that directus uses for thumbnails (private hash) - so I would also need to query the database a second time.
EDIT: I'm actually doing the search, query db, and replace (Optimized a bit by collecting the links, then going to the db once in a big query, then do the replace). I haven't found an easier way of doing it.

How to display the images in offline using ionic

I have a gallery module, the functionality implemented in this module as below
- getting the file path from the server using ajaxrequest
- the response will be json object of all image file path
- setting the filepath in image src attribute
As we are using ajax request, the images are loading in online mode only.
so how to implement the functionality so that images should show in offline also.
You may consider returning images as base64 string from the server and store them in a localstorage.
On the view use data-ng-src directive like this .
In your controller check if there is no connection and set base64 string from the localstorage as this: $scope.data.image_url=
After loading an image once, your best bet is going to be get a base64 representation of it, and then persisting that to disk.
Get the base64 representation of the image here:
Get image data in JavaScript?
Write the base64 data to disk using ng-cordova/ionic native and the writeFile method using the Cordova file plugin.
http://ngcordova.com/docs/plugins/file/
writeFile(path, file, data, replace)
There are some great answers here that I would like to build on...
I would suggest using PouchDB as a cache for base64 and/or Blob data after you have downloaded the original (one of my apps does the same thing with mp3 data converted to a Blob). You could then implement a method that checks the cache for the image before making a network request.
Nolan Lawson has created an excellent library for these binary conversions: https://github.com/nolanlawson/blob-util
Just save the base64 string to your PouchDB instance after the initial download, you can then check for that data before your app reaches out to the network.
Just beware of storage limits on iOS Safari (~50mb default)...

What's the best way to download multiple images and display multiple UIImageView?

I need to download images from a website and display them on(?) multiple UIImageView.
Maybe I'll code a php to "read" the directory and search for images, write a XML file and use it as medium. But I'm not sure if it's the best way.
Let's see the options you have to fetch images from a website:
Fetching HTML and Parsing the HTML to find the images (on the iphone). Then downloading the images.
Writing a script (maybe PHP) that writes all image links to an XML file (or JSON), and then fetch the output of your script with all the links.
If you choose option (1) you'll need NSURLConnection to fetch data asynchronously (without blocking the UI). I would also use TFHpple to parse HTML using xpath queries, see this tutorial for help. Finally to fetch the images using their URLs you can use SDWebImage, SDWebimage also provides caching so your app will not download the same image multiple times.
The bad side of using option (1) is that any change in the Website you're getting the images from will break your app and you'll need to issue an update to the app store in order to fix it.
If you choose option (2), your app will be easier to fix if the website changes, you'll just need to modify your script.
If you go with option (2) you'll probably need NSURLConnection, NSXMLParser (or a third party XML parsing library) and to download the images I would recomend SDWebImage again. I would also advise using JSON (and NSJSONSerialization) instead of XML, just beacuse I find JSON easier to parse.
Yes, it will be very good if you write some php script to get image list (list of image urls).
After getting such urls you can asynchronously download and show them in image views. Look here for such async image view implementation

How to get access to image data through browser object in powershell?

I'm trying to automate website testing using powershell. I need to compare one of the images in tag with a file on my hard drive.
Is there a way to access the file without downloading the file the second time?
.. if it's not..
Is there a way to force the browser object (ie9) to get the site without images (without changing it in the settings of the browser) and then download the images individually?