AssetImporter and cropped image removed

  • Hi,

    I've built a data importer app to import collection items with images.

    My issue is that in the collection template, the image field has multiple cropped versions:

    1. <perch:content id="image" type="image" bucket="fabrics" crop width="900" height="600" label="Image" />
    2. <perch:content id="image" type="image" bucket="fabrics" crop width="190" height="126" />

    And now the cropped images have magically dissapeared while the original image and the thumb@2x version still exists.

    The importer follows the following steps:

    1. user uploads zip file with images, and system extracts zip and imports each file saving the data result to associate with the collection items.

    2. user uploads csv file with collection item data and importer matches collection item with previously uploaded image via filename.

    3. importer uses the new assetID with the CollectionbImporter and Template to insert or update the data.

    In perch i see the collection items and images fine. Then all of a sudden it looks like perch doesn't recognize that the cropped images are assocated with any content so it cleans them.

    At least locally i have phpStorms LocalHistory function to restore but i cant publish to the server until this is figured out.

    Has anyone had an issue like this where the cropped images imported dissapear ?


  • You might be able to get some more information checking through the DB. Collections should be using revisions so you can check the collection_items table and you can check if the dynamicFieldsJSON is actually saving the assets or if they are been overwritten after the import.

  • yeah from what i've seen its in the resource_log table, the resrouces are cleaned up if they don't have an entry, but importing resources for my collection item didn't add any resource log even though it assocated the resource with the collection item.

  • Whats the structure of the data your are passing to the importer? It might be that you are using the field ID for the asset ID, which I don't think works. You should have it set similar to the following (At least its worked for me in the past)

    1. $data[
    2.     ...collection_data
    3.     'image' => true,
    4.     'image_assetID' => $assetID
    5. ]
  • So i've tried, but i don't see any difference from what I was previously doing. The assets import and are assocated to the collection items. I still don't see anything in the resource_log table to suggest that they won't be deleted though.

    Is there some sort of indexing or another funciton that needs to be called maybe ?