Description
The base name of the image.
Usage
add_filter(
'wp_data_sync_basename'
,
'my_basename'
, 10, 2
);
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'
,
'my_basename'
, 10, 2
);
function
my_basename
(
$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
;
}