Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Feature request) Support images with transparent background #361

Closed
meichthys opened this issue Aug 21, 2024 · 7 comments
Closed

(Feature request) Support images with transparent background #361

meichthys opened this issue Aug 21, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@meichthys
Copy link

Describe feature

https://www.reddit.com/r/Trilium/comments/1ew21dq/transparent_layers_in_png_files/
image

Additional Information

No response

@meichthys meichthys added the enhancement New feature or request label Aug 21, 2024
@doobes
Copy link

doobes commented Aug 21, 2024

Hoot!

Thanks guys

@SiriusXT
Copy link

SiriusXT commented Aug 22, 2024

Trilium itself displays transparent images, which can be achieved by adding the following custom css:

img.note-detail-image-view{
    background-color: #ccc;
    background-image: 
        linear-gradient(45deg, #eee 25%, transparent 25%),
        linear-gradient(-45deg, #eee 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eee 75%),
        linear-gradient(-45deg, transparent 75%, #eee 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

If you need png and other images in text notes to display a transparent background, you can try adding css:

img{
    background-color: #ccc;
    background-image: 
        linear-gradient(45deg, #eee 25%, transparent 25%),
        linear-gradient(-45deg, #eee 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eee 75%),
        linear-gradient(-45deg, transparent 75%, #eee 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

图片

@doobes
Copy link

doobes commented Aug 22, 2024

Looking through the demo info, we have this:

image

So like the SiriusXT says, it's already possible.

My question is how?

Where would you add the css referenced above?

cheers

@SiriusXT
Copy link

You can read this document to see how to add custom css:
https://github.com/TriliumNext/Docs/blob/main/Wiki/themes.md#custom-css
1:Create a css type note
图片
2:Add a note label
图片
3:Add css

img{
    background-color: #ccc;
    background-image: 
        linear-gradient(45deg, #eee 25%, transparent 25%),
        linear-gradient(-45deg, #eee 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eee 75%),
        linear-gradient(-45deg, transparent 75%, #eee 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

图片

@eliandoran
Copy link

eliandoran commented Aug 22, 2024

@meichthys , make sure you also have image compression in settings disabled otherwise I think you lose the transparency. Then re-upload the image.

Since you have a white background instead of the transparent one then most likely this is the issue. Then you can proceed with the custom CSS to add the checkmark pattern.

@meichthys
Copy link
Author

also have image compression in settings disabled

That's it! It works fine for me with compression disabled.
Closing.

@doobes
Copy link

doobes commented Aug 22, 2024

Yep!

image

Great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants