| @@ -23,8 +23,16 @@ | ||
| 23 | 23 | |
| 24 | 24 | class ImageController |
| 25 | 25 | { |
| 26 | 26 | /** |
| 27 | + * Must match `PILL_RIGHT_EDGE` in `src/Shared/lib/ai-label.js`. | |
| 28 | + * | |
| 29 | + * @var float | |
| 30 | + */ | |
| 31 | + // phpcs:ignore PSR12.Properties.ConstantVisibility.NotFound -- 7.0 floor: no const visibility | |
| 32 | + const PILL_RIGHT_EDGE = 0.85; | |
| 33 | + | |
| 34 | + /** | |
| 27 | 35 | * Upload the provided image |
| 28 | 36 | * |
| 29 | 37 | * @param \WP_REST_Request $request - The request. |
| 30 | 38 | * @return \WP_REST_Response |
| @@ -84,10 +92,10 @@ | ||
| 84 | 92 | ); |
| 85 | 93 | } |
| 86 | 94 | |
| 87 | 95 | /** |
| 88 | - * Composite the client-rendered disclosure label onto the attachment, | |
| 89 | - * bottom-right at a 16px inset, matching the canvas-path stamp. | |
| 96 | + * Composite the client-rendered disclosure label onto the attachment. The | |
| 97 | + * PNG already includes its border, unlike the canvas path's fill box. | |
| 90 | 98 | * |
| 91 | 99 | * @param int $imageId - The attachment ID. |
| 92 | 100 | * @param string $labelPath - Path to the uploaded label PNG. |
| 93 | 101 | * @return void |
| @@ -122,10 +130,10 @@ | ||
| 122 | 130 | imagealphablending($image, true); |
| 123 | 131 | imagecopyresampled( |
| 124 | 132 | $image, |
| 125 | 133 | $label, |
| 126 | - ($width - $labelWidth - 16), | |
| 127 | - ($height - $labelHeight - 16), | |
| 134 | + (int) round(($width * self::PILL_RIGHT_EDGE) - $labelWidth), | |
| 135 | + (int) round(($height - $labelHeight) / 2), | |
| 128 | 136 | 0, |
| 129 | 137 | 0, |
| 130 | 138 | $labelWidth, |
| 131 | 139 | $labelHeight, |