Hello all
Can I add a thin border to a JPG image without resorting to a theme component? I want to keep this simple and avoid, for instance, this component:
Created a very simple component to change the borders of images, oneboxes, blockquotes and staff notices shown in topics.
Allows change of the following settings
set image rounding intensity
set image border width
set image border color
set onebox rounding intensity
change onebox border width
change onebox border color
change onebox background color
set rounding blockquotes intensity
remove left border from blockquotes
set âstaff colorâ rounding intensity
topic thumbnail support for:
list roâŚ
I have tried every variation of the img
tag that I can think of. The only thing that worked was to embed the image in a kbd
tag, but that is a bit odd. This is really what I want to write:
<img src="upload://jIMXtLgb7enbLUiahXVT1Jz14n4.jpeg"
alt="photo showing derelict medium voltage power pole"
width="75%"
style="border: 1px solid gray">
And here is a sample image via standard upload:
The AI image captioning does a pretty good job, I must say. TIA!
2 Likes
Here is the earlier HTML copy/pasted in .. no border evident .. and kinda small too:
.cooked img:not(.thumbnail,.ytp-thumbnail-image,.emoji), .d-editor-preview img:not(.thumbnail,.ytp-thumbnail-image,.emoji) {
border: 4px solid red;
}
devtools hacked CSS ⌠YMMV
1 Like
custom CSS gets stripped out of posts because someone could do something like border: 1000px solid gray
and make the whole topic unreadable
You need to add some CSS to a theme or a theme component to do this, no great way around it. You can make it optional on an image-by-image basis though.
So for example, you can add this CSS to a theme:
div[data-theme-image-border] img {
border: 1px solid gray;
}
and then use it in a post like this:
<div data-theme-image-border>
<img src="yoururlhere"/>
</div>
5 Likes
Many thanks. Some followâup.
@merefield : your example worked when added as follows:
Ⱐ⸠Admin ⸠Customize ⸠Themes = Default ⸠Edit CSS/HTML ⸠Desktop ⸠CSS
@awesomerobot : I could not get your code to work, despite trying some variations.
Note that first example is siteâwide and the second example is (or rather should be) perâimage.
Any further suggestion welcome. The siteâwide solution is acceptable but a perâimage application is probably preferable.
PS: the AI captioning is deteriorating with every iteration
Heliosurge
(Dan DeMontmorency)
April 26, 2025, 8:27am
7
This Theme component maybe of interest
Created a very simple component to change the borders of images, oneboxes, blockquotes and staff notices shown in topics.
Allows change of the following settings
set image rounding intensity
set image border width
set image border color
set onebox rounding intensity
change onebox border width
change onebox border color
change onebox background color
set rounding blockquotes intensity
remove left border from blockquotes
set âstaff colorâ rounding intensity
topic thumbnail support for:
list roâŚ
@Heliosurge Tx. I had noted that component in my OP. But I will give it a try today too.
1 Like
Heliosurge
(Dan DeMontmorency)
April 26, 2025, 9:46am
9
My bad skimmed topic and missed that. But as others mentioned here you would create a custom component. The benefit though of using an existing component is potentially it is already maintained.
However TC are also handy to study and use parts of the code in your own custom works.
2 Likes
simonk
(Simon King)
April 28, 2025, 2:50pm
10
I use the âGeneric BBCode wrapperâ system for this:
I added this feature a while back and realised I didnât post about it. You can now use a special syntax in markdown to have it cooked and usable in theme components without having to write a plugin.
// wrapped in div.d-wrap
[wrap=baz foo=bar]Content[/wrap]
// wrapped in div.d-wrap
[wrap=baz foo=bar]
Content
[/wrap]
// wrapped in div.d-wrap
[wrap=baz foo=bar]
[/wrap]
// this one will be rendered as a span.d-wrap instead of a div.d-wrap
a [wrap=baz]Content[/wrap] b
The name of the component wâŚ
I put [wrap=border]...[/wrap]
around the image that I want to add a border to, along with this CSS:
.d-wrap[data-wrap="border"] {
> img, > p > img, .lightbox, .image-wrapper img {
border: 1px solid #555;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4);
}
}
2 Likes
@simonk tx, that works for me and is perâimage too.
1 Like
tobiaseigen
(Tobias Eigen)
Split this topic
April 29, 2025, 6:21pm
12