Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

Best way to put small icons inline with text?

Started by Łukasz Kondracki 9 years ago · 5 replies · 20733 views
9 years ago

I'm looking to achieve something similar to what you can see on this screenshot: image|690x128
I made *.svg icons, I linked them with [DirectDamage]: /img/DirectDamage.svg?resize=16,16 "Direct Damage" at the bottom of the page, and tried inserting them with ![][DirectDamage], but the result is... Less than satisfactory.

I did find a topic about it, but the only answer that was there was "Gotta do it with HTML" basically. Thing is, I'd rather use some easier method, like :direct-damage: or something, instead of having to always copy and paste whole lines of html code.

So here I am, asking, if there's some method of making it easy? Maybe somehow making a font of these icons and embedding it in Grav, similarly to how FontAwesome is embedded?

Ultimately something like adding ?display=inline to image link would be the best, but I'm not really up to that.

9 years ago

The easiest would be using ?class=inline-img, where you control the image through CSS - forcing its size, position, and behavior. The following CSS should get you started:

CSS
.inline-img {
  display: inline;
  margin: 0 0.125em;
  padding: 0;
  vertical-align: baseline;
}

You could further this by using shortcodes, allowing codes such as [DirectDamage], or :DirectDamage: if you prefer. This would basically entail a plugin using the ShortCode-library to parse a page's content and replacing based on a simple list of codes to look up, enclosed by your preferred delimiter.

👍 1
9 years ago

The first method works like a charm and will do for now! Thank you very much!

9 years ago

I also would recommend creating a little shortcode plugin that lets you easily use any of the fontawesome icons

9 years ago

There already is an existing plugin for that, I'm using it, of course.

9 years ago

lol, i thought I wrote one already.. Yes it's in shortcode-core plugin 🙂

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by Pedro M, 2 months ago
4 196 2 months ago
Themes & Styling · by Ian, 2 months ago
3 92 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 454 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 47 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 126 3 months ago