` in de database, met een `wp-image-123`-class eraan. * WordPress herkent dat patroon zelf in `wp_filter_content_tags()` en biedt * `wp_content_img_tag` aan, inclusief het attachment-ID dat het er al uit * heeft gehaald. Wij hoeven dus niets te raden. * * Het beeldformaat staat hier niet in de argumenten, maar meestal wél in de * classes (`size-large`). Markup leest het daaruit; ontbreekt het, dan slaan we * de hard-crop-controle over en vertrouwen we op het feit dat een * `object-position` zonder `object-fit` toch niets doet. * * @package Yinga\Focus */ declare( strict_types = 1 ); namespace Yinga\Focus\Frontend; defined( 'ABSPATH' ) || exit; final class ContentFilters { private ApplyPolicy $policy; /** * @param ApplyPolicy $policy De policy. */ public function __construct( ApplyPolicy $policy ) { $this->policy = $policy; } /** * Haakt aan. */ public function register(): void { add_filter( 'wp_content_img_tag', array( $this, 'image' ), 20, 3 ); } /** * @param mixed $filtered_image De ``-markup. * @param mixed $context Waar het vandaan komt ('the_content', …). * @param mixed $attachment_id Attachment-ID, of 0 als WordPress het niet vond. * @return mixed */ public function image( $filtered_image, $context = '', $attachment_id = 0 ) { if ( ! is_string( $filtered_image ) ) { return $filtered_image; } return Markup::apply( $filtered_image, (int) $attachment_id, $this->policy ); } }