Searching on custom fields
-
Hi,
First, thanks for the great plugin you developed as we are currently testing it and it looks to provide almost all of the functionality we are looking for.
I searched through all of the support tickets but did not see a question posed on the ability to search from the Assistant screen in custom fields.
For example, we are looking to add a custom field called photo reference where the user would put in the reference number from a stock photo site. It would be helpful for them to be able to search on that custom field to see if they used that particular image in any other article.
Is there a way to add custom fields to the search?
Thanks for your help in this.
https://www.ads-software.com/plugins/media-library-assistant/
-
Hello everyone!
I’m joining your thread as I had a similar question (in this thread) : How to filter / search media, in (Media Library) Assistant or when adding media to a post, against a custom field mapped from a parent post?
So, David your
MLA Custom Field Search Example
Plug-in from Current version (2.11) is working perfectly for me in the “Assistant” with a custom field named “ref_offer
” and all variations of the search cases you were testing earlier.
But it seems not to be extended to thesearch-box
when inserting a media to a post (I didn’t had time to take look at the code yet).My next question is how it could be integrated in the
search-box
in order to the user not to have to input thecustom:
parameter in the search field, but rather to check a checkbox with theref_offer
label for example?Please, let me know if you prefer me to create a new thread for this question or we will follow-up on this one.
Thank you in advance!
Here are my responses to your questions
1. custom:File Size
– I changed all three places in the source code that had “File Size” to “Source”
– “custom:*” brings up all records that have any value in a custom field
– “custom:Source=istock” brings back no results
– “custom:*istock*” brings back the expected result2. custom:File Size=
– I don’t believe I have a IPTC/EXIF mapping rule setup for Source. In the custom fields mapping, the Data Source is set to None
– However, what I did notice when looking further is that the records that only have a value for External ID and not Source in the listing do have a Source field listed when you go to edit although it is blank. If I remove that field then the record appears in the results of this search, as it should. I uploaded a new image and from the table went to Quick Edit. I entered in a value for External ID but nothing for Source and then updated. This new record will not show in the search results. If you go to edit the record, there is a Source field that is blank. So it looks that the Quick Edit adds all additional custom fields but with blank values if nothing is enteredI also filled out the form on the link you sent in order to get an address to send an error log for issue #1
Thank you again for your assistance
Thanks for adding your input to this topic. I have just uploaded a new Development Version dated 20150617. This version contains an updated mla-custom-field-search-example.php.txt custom plugin that extends the
custom:
search prefix to the Media Manager Modal (popup) Window. It was an easy addition and a great suggestion, thanks!I have also thought about and investigated your second suggestion to replace the
custom:
prefix and “check a checkbox with the ref_offer label for example“. I have decided against this alternative for a few reasons:- A checkbox implies that the custom field is added to the other Search Media fields such as Title and Description. Searching for NULL or non-NULL values has no meaning for the other fields.
- Without the prefix, the “field name = value” parts of the content would be confusing.
- The complexity of the code required to add and manage custom checkboxes is significant.
Extending the Search Media box for custom field searches is a bit of a hack but I thought it reasonable given the extra utility it provides. The current implementation is as far as I plan to go.
Thanks again for your contributions and for your understanding.
@bfi-wp –
Thank you for your additional test results for giving me your contact information and for working with me offline on this issue.
I believe your “custom:istock” problem may be due to some confusion I created by selecting “File Size” as my example default field. File Size is a numeric field, and MLA pads it out on the left to 15 characters so it will sort sensibly in the Media/Assistant submenu table. Your “Source” field is a non-numeric text field and is not padded in the same way.
The third occurrence of “File Size” in the example code pads the search value out to match the database content. Your “Source” field should not be named in this
in_array( ...
statement.Try taking “Source” out of the
in_array()
list and re-running your tests.1. custom:File Size
– I removed “Source” out of the third occurrence and all of the tests worked great!2. custom:File Size=
– This search works as expected. The only related issues is the one I mentioned in my previous post regarding the updating of all custom fields in the Quick Edit. Here is a recap again from my previous post:“I uploaded a new image and from the table went to Quick Edit. I entered in a value for External ID but nothing for Source and then updated. This new record will not show in the search results. If you go to edit the record, there is a Source field that is blank. So it looks that the Quick Edit adds all additional custom fields but with blank values if nothing is entered”
I also tested the custom: search prefix in the Media Manager Modal (popup) Window and it works great
Thank you for your update with the good news regarding the final issues with the custom field search plugin. If you find any other problems, let me know.
I have uploaded a new Development Version dated 20150621 that contains several fixes to correct the “blank values” issue in the Quick Edit and Bulk Edit actions. This version respects the Delete Null Values option when it is specified in a Custom Field mapping rule.
This new version also adds the Format, Option and Delete Null Values options to IPTC/EXIF mapping rules, correcting the problem I found while researching your issue.
You can find step-by-step instructions for using the Development Version in this earlier topic:
I will leave this topic unresolved until the new code is released in the next MLA version. If you get a chance to try the Development Version, let me know if it corrects your custom field “blank values” problem. Thanks for working with me on these issues and for your interest in the plugin.
2. custom:File Size=
– I installed the latest Development version and enabled the Delete NULL values option for both my custom fields. With that option enabled the records appear as they should in the search results even after being updated using the Quick Edit.Thanks for this fix. All issues are resolved
Thanks for the update with your good news. As I said, I will mark this topic resolved when the next MLA version goes out.
If there is anything else I can do, let me know.
Hi David,
Thank you for the extension a lot, it’s working great!!! And I understand regarding the changing of ‘method’. =)
Also I’ve a problem when underscore and wildcards are combined together. I’m using SVN version 20150713
My
ref_offer
field is containing a string which is always starting with four identical caracters :PAN_
, then it can be a combination of letters and numbers.My problem is the following :
cutom:ref_offer=PAN*
is working as expectedcutom:ref_offer=PAN_A15
is working as expectedcutom:ref_offer=PAN_*
returns no resultscutom:ref_offer=PAN_A*
returns no resultscutom:ref_offer=PAN*A*
is working as expected
I’ve enabled the Debug tab, but the log is empty…. =(
Thank you in advance!
Thank you for your positive feedback and for posting all the examples of your search strings; very helpful. I was able to test with your examples and reproduce the failure cases
PAN_*
andPAN_A*
.I have found and fixed two defects that should resolve your problem:
- The way logging is controlled has changed and the current example plugin no longer activates logging when
<|>
is added to the beginning of the search string. I have updated the example plugin (to version 1.04) and fixed that. - The underscore (“_”) character is a special character in the SQL “LIKE” clause and MLA did not handle it correctly. I have updated my Development Version to fix that.
I will be releasing a new Development Version shortly and I will update this topic to let you know when you and download and try it out. Thank you for reporting this issue and for your patience in awaiting a fix.
I have released a new Development Version dated 20150719 that contains the fixes described in my earlier post. Note that the example plugin has also changed to restore logging.
If you get a chance to install and test it let me know if it resolves your problems. Thanks again for bringing them to my attention.
I have just released MLA version 2.13, which contains the final version of the example plugin and the MLA changes required to support it.
I am marking this topic resolved, but please update it if you have any problems with the new release. Thanks for your patience and your interest in the plugin.
- The topic ‘Searching on custom fields’ is closed to new replies.