I always want to have images that will adapt to the dark or white theme. But with JPEG files it is more the dream. Nevertheless I found one interesting hack that you can make something like that.
INPUT
The source images are JPG files white white background.
![[image.jpg#invert_B]] - use when image (mostly white) > fits for dark theme ![[image.jpg#invert_W]] - use when image (mostly black) > fits for light theme
“Adaptive inversion” + Contrast
![[image.jpg#invert_B_C]] - image (mostly white) > fits for dark theme + add contrast ![[image.jpg#invert_W_C]] - image (mostly black) > fits for light theme + add contrast
Man, this is fantastic work Den.
You really are a life savior.
This should be one of the most talked about snippets.
Thanks a million sir. Keep up the good work. The blending of image background into the primary background of the theme is phenomenal.
Great code. I noticed that this only works in reading mode and not in editing mode. I fiddled with it, and using the image alt instead of source makes the changes in both reading and editing mode.
Also, since spans are rendered in the reading mode, you’d have to refer directly to the img tag. The image alt is the source by default. So:
Update - I noticed that this snippet interferes with the CSS in the Banner-plugin (filename became visible in the banner image). Solved (kind of ) by removing the mix-blend-mode for theme-dark and .theme-light