Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor AlexandreT

    (@alexandret)

    Hello,

    I’m not sure to exactly understand what you need. Do you want to be able to index all kind of attachments but, if attachment is an image, do not index the title of the attachment but still index it as a document?
    And thus be able to get it in the result but with no title?

    If that is so we could easily add a new WordPress “action” at the beginning of the internal function “opensearchserver_add_documents_to_index()” and you would then be able to write this code in your functions.php file:

    add_action('oss_index_document_begin', 'oss_index_document_begin', 10, 5 );
    function oss_index_document_begin($document, $index, $lang, $post, $customFields = null) {
        if(strpos($post->post_mime_type, 'image') !== false) {
            $document->newField('title', '');
        }
    }

    I just tested it and it works. Attachments get indexed, and if attachment is an image it does not get any title. When displaying results the default template embedded in the plugin will display “Un-titled”.

    Please tell me if this is what you need so I can update the plugin and release a new version.

    Regards,
    Alexandre

    Thread Starter oblamine

    (@oblamine)

    Hello,
    This is not exactly what i want to get.
    1- I do not want to have attached image displayed in results page
    2- I do not want to index images included in attachments.
    regards

    Plugin Contributor AlexandreT

    (@alexandret)

    Hi,

    Please update to version 1.5.6 of the plugin and add this PHP code in the functions.php file of your active theme:

    add_filter( 'oss_abort_index_document', 'oss_abort_index_document', 1, 4 );
    function oss_abort_index_document($document, $index, $lang, $post) {
        if($post->post_type == 'attachment' && strpos($post->post_mime_type, 'image') !== false) {
            return true;
        }
        return false;
    }

    Then re-index all your data and telle me if it worked as excepted for you.

    Thank you,
    Alexandre

    Thread Starter oblamine

    (@oblamine)

    it works perfectly!! thank you very much

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘OSS & attachement indexation’ is closed to new replies.