Description
The base name of the image.
Usage
apply_filters(
'wp_data_sync_basename'
,
$basename
,
$post_id
);
Parameters
$basename | string | Image basename | $post_id | int | The WordPress post ID |
Code Example
Use the post title as the base name for the post thumbnail.
add_filter(
'wp_data_sync_basename',
function
(
$basename
,
$post_id
) {
if
(
$title
=
get_the_title
(
$post_id
) ) {
$file_type
=
wp_check_filetype
(
$basename
);
$slug
=
sanitize_title
(
$title
);
return
"
{
$slug
}
.
{
$file_type
[
'ext'
]
}
"
;
}
return
$basename
;
), 10, 2 );