Support » Plugin: Media Sync » Attachment metadata could not be generated from

  • rosariobocca



    when importing pdf files i get this error Attachment metadata could not be generated from......
    The file is present in the media gallery but does not report the reference to the post in which it was uploaded. This generates problems for me with files accessible only to registered users, because if that post is only accessible via login, the files loaded in that post can only be accessed after login but in this way it does not work,
    do you have a solution to solve? 
    I use UAM plugin for reserved area management.
    thank you
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author erolsk8


    Hi @rosariobocca, I’m not sure if this plugin can preserve file’s reference to the post. Because all that this plugin knows is what’s in the actual file (name, file type, in which folder it is, etc.), but it doesn’t have any reference to where that file was previously used in WordPress.

    I mean, it might be possible to find that relation by file name, but I didn’t try to do that.

    So, unfortunately, you could only “reconnect” it to the post manually afterward. Or maybe there is some plugin that does that automatically 🙂


    Thread Starter rosariobocca


    ok @ erolsk8

    thanks if you find a plugin or give me some tips on how to do it I would be grateful.

    I saw on the net that wp_update_attachment_metadata

    or I have read that perhaps with Health Check & Troubleshooting you could find a solution but I have not yet understood how.

    thanks again for your work.

    Plugin Contributor Simon Kane


    I actually use the filter in Media Sync to attach files to products and pages. This is done by having the filename being imported follow a set of site/client-specific rules that tell the code what the file is for.

    I think you need a developer to create the necessary custom code specific to your need.

    Plugin Author erolsk8


    Hey @rosariobocca, as Simon said, it should be possible to do it by writing some custom code.

    This can be a starting point with some developer-friendly instructions:

     * Apply this filter to collect additional metadata and/or to run some additional actions,
     * e.g. to "auto-connect" items to pages, posts, and WooCommerce products.
     * Returning empty data will skip updating metadata (wp_update_attachment_metadata),
     * so this filter can also be used to totally overwrite updating attachment metadata.
     * This filter can be used in a number of different ways:
     * 1. to collect additional metadata,
     * 2. to run some additional custom actions
     *   (e.g. to "auto-connect" items to pages, posts, and WooCommerce products),
     * 3. to skip or completely overwrite updating the metadata (<code>wp_update_attachment_metadata</code> function),
     *   when this filter returns empty data (null).
     * NOTE:
     * Things could break if the filter doesn't return proper attach data
     * and it hasn't created/updated the <code>wp_postmeta</code> table record (meta_key _wp_attachment_metadata).
     * @since 1.2.5
     * @param array $attach_data Data received from WP function: wp_generate_attachment_metadata
     * @param int $attach_id
     * @return array|null
    function my_custom_media_sync_before_update_metadata($attach_data, $attach_id)
      // Custom logic here
      return $attach_data;
    add_filter('media_sync_filter_before_update_metadata', 'my_custom_media_sync_before_update_metadata', 10, 3);

    But I never really tried to use it myself, that’s Simon’s contribution 🙌

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Attachment metadata could not be generated from’ is closed to new replies.