I’m making an effort to make my og images better yet again, I’m going for that next 10% better. I really like my og images, but there are some title sizes that overflow. This page is a page to help debug. How I make these og images is for another day.
Script ¶ #
I use my own static site generator markata. I can use it to generate a list of posts wrapped in their og image. I use itertools to do a groupby so that I can do roughly every 5 characters larger, and see a wide variety of sizes.
from markata import Markata
from itertools import groupby
markata = Markata()
lens = [{'length': len(post.title), 'title': post.title, 'slug': post.slug} for post in m.posts]
lens_sorted = sorted(lens, key=lambda x: x["length"])
groups = {
k: list(g)
for k, g in groupby(lens_sorted, key=lambda x: (x["length"] // 5) * 5)
}
posts = [g[0] for g in groups.values()]
ogs = [ f'[![{post["title"]}](https://shots.waylonwalker.com/shot/?url=https://waylonwalker.com/{ post["slug"] }/og/&height=600&width=1200&scaled_width=1200&scaled_height=600&format=jpg&v=4)](https://waylonwalker.com/{ post["slug"] }/og/)' for post in posts]
print("\n\n".join(ogs))
OG-Sample ¶ #
shots ¶ #
I also do Posts tagged: shots posts that change the og template quite a bit by adding the image to the page. I’ll do the same script, but add a filter to the images.
from markata import Markata
from itertools import groupby
markata = Markata()
lens = [{'length': len(post.title), 'title': post.title, 'slug': post.slug} for post in m.filter('templateKey=="shots" and "family" not in tags')]
lens_sorted = sorted(lens, key=lambda x: x["length"])
groups = {
k: list(g)
for k, g in groupby(lens_sorted, key=lambda x: (x["length"] // 5) * 5)
}
posts = [g[0] for g in groups.values()]
ogs = [ f'[![{post["title"]}](https://shots.waylonwalker.com/shot/?url=https://waylonwalker.com/{ post["slug"] }/og/&height=600&width=1200&scaled_width=1200&scaled_height=600&format=jpg&v=4)](https://waylonwalker.com/{ post["slug"] }/og/)' for post in posts]
print("\n\n".join(ogs))