fabianmichael / kirby-meta

All-in-one solution to all of your SEO/OpenGraph/JSON-LD needs. 👀

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use thumb presets for easier thumbnail customisation

Daandelange opened this issue · comments

Hello (again),
[sorry for posting quite some issues, I'm implementing your plugin and thinkering at the same time :) ]

Context:
I'm using a custom thumb driver to customise how thumbs are generated generally and would like to use it to customise the OG image thumb too. Long story short, this is way more easy and robust using thumb presets when calling $file->thumb() (otherwise requiring to check the thumb settings argument against known preset values).

Motivation:
Be it with or without custom thumb driver, I think there are situations where one wishes customise the thumb function used by this plugin, and it would be possible if it registers and uses a thumb preset rather then hardcoded thumb parameters. (example: change the thumb quality for the og-image).
This will also make it easier to generate an og-image-thumb manually from usercode by providing a specific preset.

Sure, this is already possible with the hooks by removing the corresponding thumb tags and generating a thumb again to put it back as a html tag, but that feels heavy.

Proposal:
So I'm asking to make the OG image thumb easier to customise/hook-up by switching from hardcoded thumb parameters to a thumb preset.

  1. Register a thumb preset
  2. Modify all calls to thumb()

Two issues for the implementation, which make them more difficult to maintain.

  • There is no thumb presets API for extensions/plugins. But it's possible to register thumb presets from a plugin "hacking" trough the system.loadPlugins:after plugin hook and calling $kirby->extend(['options'=>'thumbs.presets.ogimage'=>[...]], null).
  • The thumb parameters used in the plugin are dynamic (format), and I can't think of a workaround to make a preset dynamic or to override a preset.

@Daandelange No need for that, there’s already an API for overriding the deafult og:image of a page. I just added it to the docs: https://github.com/fabianmichael/kirby-meta#providing-metadata-from-page-models

Awesome, thanks ! :)