Skip to content Skip to sidebar Skip to footer

Modifying A Clipboard Content To Be Treated As Html

When I “copy an image” on the web (by highlighting the image and ctrl+C) and then passed it into the text view of the HTML WYSIWYG editor (not the source code editor) the pictu

Solution 1:

I want to be able to add the image to the HTML WYSIWYG editor without having to switch to the source code editor

AHK solution: use a hotkey like ctrl+shift+v

you have plain text in clipboard: https://cdn.sstatic.net/Img/teams/teams-illo-free-sidebar-promo.svg?v=47faa659a05e go in WYSIWYG editor and press ctrl+shift+v, it will be pasted in HTML format HTML format is a clipboard format, so an image will be shown. what you need is here: WinClipv2\imgSrc to HTML Format\src in clip.ah2 I put the code in a repo because there's a library to include: https://github.com/FuPeiJiang/WinClipv2 READ the README.md

Solution 2:

You can do this:

  1. Install HtmlClipboard : copy the script, save it as HtmlClipboard.py in C:\Python##\Lib\site-packages\
  2. Save the script below as image_link_as_html.py(I used some of your code in your question):
  3. Create a shorcut for the script in step to (right click on the file image_link_as_html.py, and select create a shorcut)
  4. Right click on the shorcut, select Properties, and and add a keyboard shorcut in Shorcut key.

That's it. When you have an image url in our clipboard, you can just press your keyboard shorcut and you can paste your image directly in the html mode of you editor.


image_link_as_html.py (Python34):

from tkinter import Tk
root =Tk()
root.withdraw()
image_url = root.clipboard_get()

# send <img src="https://image_url" alt=""/>  to an "HTML format clipboard"import HtmlClipboard
HtmlClipboard.PutHtml("<img src=\"http://"+image_url+" \" alt=\"\"/>")

To address the part about ShareX, you could use this scrip instead:

from tkinter import Tk
root = Tk()
root.withdraw()
UrlShareX = root.clipboard_get()

# remove everything except the file google ID: this part is not needed 
UrlShareX=UrlShareX.replace("https://drive.google.com/file/d/", "") 
UrlShareX=UrlShareX.replace("/view?usp=drivesdk", "")
UrlShareX=UrlShareX.replace("/view?usp=sharing", "")
UrlShareX=UrlShareX.replace("https://drive.google.com/open?id=", "")
UrlShareX=UrlShareX.replace("/view", "")

# send <img src="https://drive.google.com/uc?export=view&amp;id=xxx " alt="" />  to an "HTML format clipboard"
import HtmlClipboard
HtmlClipboard.PutHtml("<img src=\"https://drive.google.com/uc?export=view&id="+UrlShareX+" \" alt=\"\"/>")

Post a Comment for "Modifying A Clipboard Content To Be Treated As Html"