-
Notifications
You must be signed in to change notification settings - Fork 132
Closed
Labels
Bug: AcceptedBug has been confirmed, is reproducible, and ready to work on.Bug has been confirmed, is reproducible, and ready to work on.
Description
Currently, pro search indexes file data by simply using the content of the field's table- i.e.,
This isn't useful- we need the filename in there. We could put more- like captions or some such. But at least the filename.
I have a solution that works, but I'm not at all sure it's the correct solution, so making this an issue rather than a pr.
In ft.file.php if you add this method:
// prep data for pro search- give it the filename
function third_party_search_index($data) {
//ee()->file_field->parse_field($field_data);
if (is_string($data) && preg_match('/^{file\:(\d+)\:url}/', $data, $matches)) {
// If the file field is in the "{file:XX:url}" format
// Set upload directory ID and file name
$file_id = $matches[1];
$file = ee()->file_field->get_file($file_id);
return (string) $file['file_name'];
} elseif (is_string($data) && preg_match('/^{filedir_(\d+)}/', (string) $data, $matches)) {
// If the file field is in the "{filedir_n}image.jpg" format
$dir_id = $matches[1];
$file_name = str_replace($matches[0], '', $data);
return $file_name;
}
return '';
}
Then when you index, you get the filename in the index. It sanitizes it, stripping out dashes and periods, but... that may well be fine. I'm just not 100% sure this is the best way to go. But it does work.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Bug: AcceptedBug has been confirmed, is reproducible, and ready to work on.Bug has been confirmed, is reproducible, and ready to work on.