@Moonbase59 - Thank you so much for your work on clean-embeds!
I can’t reply to the original thread, so I believe this to be the next best spot. This is an adjustment for anyone who finds this post through the same Google pathways I did.
It seems that as of today (2025-03-28) the class references are no longer linking correctly, at least for edit mode. I assume Obsidian may have changed the embedding data structure since this was originally written, so I took the liberty of adjusting the classes in the CSS.
This has been not fully tested; I was originally wanting to omit vertical scrolling in both reading and editing (preview) modes, as well as clean up the look of my embeds - I can confirm that these functions do indeed work with this updated code.
This code still requires the cssclass: clean-embeds
in the frontmatter. If you’d like to give this a try, just follow the original instructions, using the code below.
I do not in any way claim ownership or authorship of this code. @Moonbase59 did all the work.
Updated clean-embeds.css
/*
clean-embeds.css snippet
Removes title, link, padding, margins from embeds,
so they really look like the same note.
To be used with `cssclass: clean-embeds` in YAML frontmatter.
2021-08-24 Matthias C. Hormann (Moonbase59)
TODO: Find out how to correct PDF export. L/R margins & vspace too large on embeds.
*/
/* remove title and the table from the "Metatable" plugin */
.clean-embeds .markdown-preview-view .markdown-embed-title,
.clean-embeds .markdown-preview-view .obsidian-metatable {
display: none;
}
/*
For links to embeds NOT to be shown, uncomment the following
and comment out the other section below.
*/
/*
.markdown-preview-view.clean-embeds .markdown-embed-link,
.markdown-preview-view.clean-embeds .file-embed-link {
display: none;
}
*/
/*
For links to embeds to BE shown, uncomment the following
until the "End link show/hide stuff" comment
and comment out the section above.
*/
/* Link icon */
.clean-embeds .markdown-preview-view .markdown-embed-link,
.clean-embeds .markdown-preview-view .file-embed-link {
top: 0;
right: 0;
left: unset;
text-align: right;
border: none;
margin: 0;
width: 24px;
height: 24px;
color: var(--text-faint);
cursor: pointer;
}
/* for Ars Magna theme and others that change ::before */
.clean-embeds .markdown-preview-view .markdown-embed-link::before,
.clean-embeds .markdown-preview-view .file-embed-link::before {
display: none;
}
/* Link icon size & hide */
.clean-embeds .markdown-preview-view .file-embed-link svg,
.clean-embeds .markdown-preview-view .markdown-embed-link svg {
height: 24px;
width: 24px;
opacity: 0;
display: unset;
}
/* show on hover */
.clean-embeds .markdown-preview-view .markdown-embed:hover .file-embed-link svg,
.clean-embeds .markdown-preview-view .markdown-embed:hover .markdown-embed-link svg {
opacity: 1;
}
/* change background on hover, to exactly see what’s embedded */
.clean-embeds .markdown-preview-view .markdown-embed:hover,
.clean-embeds .markdown-preview-view .file-embed:hover {
background-color: var(--background-secondary) !important;
}
/* End link show/hide stuff */
/* remove border and scroll */
/* unfortunately needs !important for some themes */
.clean-embeds .markdown-preview-view .markdown-embed,
.clean-embeds .markdown-preview-view .file-embed {
border: none !important;
padding: 0 !important;
margin: 0 !important;
}
.clean-embeds .inline-embed .markdown-embed-content,
.clean-embeds .markdown-preview-view .markdown-embed-content,
.clean-embeds .markdown-preview-view .markdown-embed-content>.markdown-preview-view {
max-height: unset;
padding: 0 !important;
/* !important for "Pisum" theme */
margin: 0;
border: 0;
}
/* remove <br> between internal embeds */
.clean-embeds .markdown-preview-section div>br {
display: none;
}
/* remove vertical space added by markdown-preview-sizer */
.clean-embeds div.markdown-preview-sizer.markdown-preview-section {
min-height: unset !important;
padding-bottom: 0 !important;
}
/* special considerations for printing (PDF export) */
@media print {
/* remove frontmatter box if "Show frontmatter" was enabled */
/* Also remove metadata table from "Metatable" plugin */
pre.frontmatter,
.obsidian-metatable {
display: none;
}
}
Original Post