From "examples and demos": d&d of images
From "examples and demos": d&d of images
Can you update this demo to show how to process image dragged from browser?
When you drag some image from Firefox for example it sends only link to that image but not image itself.
I know how to download and insert image into RVE but I'm not sure about the better way to do it.
When you import HTML you get OnImportPicture event but when you drag some image from another app RVE fires OnOleDragDrop (the hard way) and OnReadHyperlink (this one should be used as I think).
The problem is if I insert picture in OnReadHyperlink event (and set StyleNo:=rvsPicture) I get new item and all current item data are not valid.
Please help.
BTW I use CleverComponents for image downloading so simple code for image downloading is enough:
clDownloader.URL:='...url.png';
clDownloader.Start(False);
When you drag some image from Firefox for example it sends only link to that image but not image itself.
I know how to download and insert image into RVE but I'm not sure about the better way to do it.
When you import HTML you get OnImportPicture event but when you drag some image from another app RVE fires OnOleDragDrop (the hard way) and OnReadHyperlink (this one should be used as I think).
The problem is if I insert picture in OnReadHyperlink event (and set StyleNo:=rvsPicture) I get new item and all current item data are not valid.
Please help.
BTW I use CleverComponents for image downloading so simple code for image downloading is enough:
clDownloader.URL:='...url.png';
clDownloader.Start(False);
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
When dragging from a browser, the browser provides data in multiple formats, and TRichViewEdit chooses from available formats.
So, when dragging an image:
- from Edge, TRichViewEdit inserts a plain text (the image URL),
- from Chrome/FireFox, TRichViewEdit inserts a hyperlink (to the image URL).
Currently, TRichViewEdit chooses formats in the following order:
1) RVF
2) RTF
3) hyperlink
4) plain text
5) bitmap
6) metafile
7) files
Well, I think files must be moved higher, between RTF and hyperlink. It will be included in the next update.
It solves the problem with Edge (and I believe, in Internet Explorer too): it provides data as an image file in the browser cache.
But, as I can see, FireFox/Chrome does not provide data as an image, neither as bitmap/metafile nor as a file. So TRichView continues inserting it as URL.
Well, of course, TRichViewEdit can check if the dropped link is a link to a picture, download this picture and insert, but I believe it should not do it. No other editor does it. For example, MS Word inserts this image as a hyperlink too.
So, when dragging an image:
- from Edge, TRichViewEdit inserts a plain text (the image URL),
- from Chrome/FireFox, TRichViewEdit inserts a hyperlink (to the image URL).
Currently, TRichViewEdit chooses formats in the following order:
1) RVF
2) RTF
3) hyperlink
4) plain text
5) bitmap
6) metafile
7) files
Well, I think files must be moved higher, between RTF and hyperlink. It will be included in the next update.
It solves the problem with Edge (and I believe, in Internet Explorer too): it provides data as an image file in the browser cache.
But, as I can see, FireFox/Chrome does not provide data as an image, neither as bitmap/metafile nor as a file. So TRichView continues inserting it as URL.
Well, of course, TRichViewEdit can check if the dropped link is a link to a picture, download this picture and insert, but I believe it should not do it. No other editor does it. For example, MS Word inserts this image as a hyperlink too.
This is exactly what I want to implement.Sergey Tkachenko wrote:Well, of course, TRichViewEdit can check if the dropped link is a link to a picture, download this picture and insert, but I believe it should not do it.
If you drag image from firefox or chrome to windows explorer it will save this image, not URL. I want to do the same.
When you drag image from the browser to RVE who needs it's URL? Right - nobody. Everyone want to see that image.
Please help to implement it. I will check dropped link if it's URL to an image and download it manually.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
By picture extension at the end (like http://www.web.com/pic.png)
In my case real picture is most important than it's link.
Anyway I would like to implement it. What is the better way?
In my case real picture is most important than it's link.
Anyway I would like to implement it. What is the better way?
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Ok it almost works but my ChangePicture procedure cannot find that image to replace placeholder because there is no URL attached to placeholder.
Where should I check for it?
When I import from HTML all imported images come with ItemURL set.
Where should I check for it?
When I import from HTML all imported images come with ItemURL set.
Code: Select all
RVData.GetItemExtraStrProperty(i, rvespImageFileName, ItemURL);
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Ok, works now but looks like RichViewActionTest doesn't redownloads dragged image. Do you have a demo how?
Even rvoAssignImageFileNames is not enabled there.
Do I still need to download that image?
Because right now it inserts image (as I can see) then changes it to a placeholder image and then my app downloads it again.
I'm a bit confused.
Even rvoAssignImageFileNames is not enabled there.
Do I still need to download that image?
Because right now it inserts image (as I can see) then changes it to a placeholder image and then my app downloads it again.
I'm a bit confused.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
The image should be downloaded one time.
1) You need to define a downloader.
Place on the form:
- RVAControlPanel1: TRVAControlPanel*
- RVAIndyDownloadInterface1: TRVAIndyDownloadInterface
- IdHttp1: TIdHttp,
Assign:
- RVAIndyDownloadInterface1.IdHttp = IdHttp1
- RVAControlPanel1.DownloadInterface = RVAIndyDownloadInterface1
2) Process TRichViewEdit.OnBeforeOleDrop and OnAfterOleDrop events to enable image downloading for drag&drop. The code can be found in the help file, in the topic about these events.
---
Note *: there should be a single TRVAControlPanel in an application (if you use multiple control panels, you need to assign them to actions and combo boxes manually)
1) You need to define a downloader.
Place on the form:
- RVAControlPanel1: TRVAControlPanel*
- RVAIndyDownloadInterface1: TRVAIndyDownloadInterface
- IdHttp1: TIdHttp,
Assign:
- RVAIndyDownloadInterface1.IdHttp = IdHttp1
- RVAControlPanel1.DownloadInterface = RVAIndyDownloadInterface1
2) Process TRichViewEdit.OnBeforeOleDrop and OnAfterOleDrop events to enable image downloading for drag&drop. The code can be found in the help file, in the topic about these events.
---
Note *: there should be a single TRVAControlPanel in an application (if you use multiple control panels, you need to assign them to actions and combo boxes manually)