ozntel / oz-image-in-editor-obsidian

This Obsidian plugin to view Images, Transclusions, iFrames and PDF Files within the Editor without a necessity to switch to Preview.
339 stars 13 forks source link

Change Default for all image sizes #81

Closed csss1234 closed 3 years ago

csss1234 commented 3 years ago

using Minimal theme, I have a css snippet that renders all images as 40% size in preview mode

.markdown-preview-view .image-embed img:not([width]) { width:40%; }

is there a way to do the same in editor?

ozntel commented 3 years ago

You can use the same logic:

.oz-image-widget img:not([width]){
    width: 40%;
}
csss1234 commented 3 years ago

Thanks! Works great. I ended up using

.oz-image-widget img:not([width]){
max-width: 250px;
}

and combining it with code borrowed from Kepano

.oz-image-widget img:active {

    max-height:100%;
    max-width:100%;
    height:100%;
    width:100%;
    object-fit: contain;
    margin:0 auto;
    text-align:center;
    top: 50%;
    transform: translateY(-50%);
    padding:0;
    left:0;
    right:0;
    bottom:0;
    background:var(--background-primary);}

To get zoomable thumbnails : )

JohnV7 commented 3 years ago

Nice!, And how can one change the default size in editor mode? This does not work div.oz-image-widget{ max-width: 75%; }

ozntel commented 3 years ago

Nice!, And how can one change the default size in editor mode? This does not work div.oz-image-widget{ max-width: 75%; }

You are trying to size the div. It won't work. You need to target the image:

div.oz-image-widget img{
    max-width: 75%
}
JohnV7 commented 3 years ago

thanks, but this does not work either. Even adding the important property div.oz-image-widget img{ max-width: 75% !important; }

ozntel commented 3 years ago

Then you need to check your other custom CSS snippets. There should be a some styling, which takes more priority if !important even doesn't work. You can try in an empty vault to see which part causes this issue.

JohnV7 commented 3 years ago

ok, it works after restarting obsidian. For some reason the changes do not get applied immediately. Thanks for your help