filtrod 2.5.0
jpeg_quality
Opis
Ustawia jakość kompresji obrazów JPEG generowanych przez WordPress.
Przykład użycia
add_filter( 'jpeg_quality', ... )php
add_filter( 'jpeg_quality', 'wpdocs_jpeg_quality' );
function wpdocs_jpeg_quality( $quality ) {
return 82;
}
add_filter( 'jpeg_quality', 'wpdocs_jpeg_quality' );
function wpdocs_jpeg_quality( $quality ) {
return 82;
}Applies only during initial editor instantiation, or when set_quality() is run manually without the $quality argument.
The WP_Image_Editor::set_quality() method has priority over the filter.
The filter is evaluated under two contexts: 'image_resize', and 'edit_image', (when a JPEG image is saved to file).
Parametry
| Parametr | Typ | Opis |
|---|---|---|
$quality | int | Quality level between 0 (low) and 100 (high) of the JPEG. |
$context | string | Context of the filter. |
Wywołanie
Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'jpeg_quality', 'twoja_funkcja', 10, 2 );
function twoja_funkcja($param_1, $param_2) {
// Twój kod
}
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'jpeg_quality', 'twoja_funkcja', 10, 2 );
function twoja_funkcja($param_1, $param_2) {
// Twój kod
}Popularne w tej kategorii