Silverstripe Dropzone not publishing uploaded images

4+

After uploading an image from a front end form using the dropzone addon, once uploaded it doesn’t display unless I publish the image in the CMS:

I have a DataObject called Listings. In Listings I have an image called HostImage, it is a has_one and is owned


<?php
namespace SilverStripe\MyNameSpace;

use ...


class Listings extends DataObject {

    private static $db = [];
    
    private static $table_name = 'Listings';

    private static $owns = [
        'HostImage'
    ];
    
    private static $summary_fields = [
        'HostImage.CMSThumbnail' => '',
    ];
    
    private static $has_one = [
        'HostImage' => Image::class,
    ];  

    public function getCMSFields() {
        
        $fields = parent::getCMSFields();

        $fields = FieldList::create(TabSet::create('Root'));
        $fields->addFieldsToTab('Root.Main',[
            UploadField::create('HostImage', 'Host Image')
                ->setFolderName('Listings')
                ->setAllowedExtensions(array('jpeg','jpg'))
        ]);
        return $fields;  
    }
        

    public function canView($member = null) 
    {
        return true;//Permission::check('CMS_ACCESS_CMSMain', 'any', $member);
    }

    public function canEdit($member = null) 
    {
        return true;//Permission::check('CMS_ACCESS_CMSMain', 'any', $member);
    }

    public function canDelete($member = null) 
    {
        return Permission::check('CMS_ACCESS_CMSMain', 'any', $member);
    }

    public function canCreate($member = null, $context = []) 
    {
        return true;//Permission::check('CMS_ACCESS_CMSMain', 'any', $member);
    }
}

Then I have a front end form on a page the utilises the Dropzone addon: https://addons.silverstripe.org/add-ons/unclecheese/dropzone to fill out the Listings fields, upload the HostImage and save to the Listings object.

The dropzone area works, the file uploads to the correct folder, when I save the form the Listings and File objects are updated.

However I cannot view the images in the CMS or the front end thumbnails unless I go to the Image in the CMS and publish it. Once the image is published I can view the thumbnail and image in the CMS and I can view the saved dropzone thumbnail image.

After the front end form is saved I’ve tried publishing the HostImage and the Listings object but it doesn’t let me view the thumbnails.

use UncleCheese\Dropzone\FileAttachmentField;
...
$form->saveInto($Listing);
$SavedListing = Listings::get()->byId($data['ListingID']);
$SavedListing->write();

if( $Listing->HostImageID ){
    $Listing->publishRecursive();
    $HostImage = Image::get()->byID($Listing->HostImageID);
    if( $HostImage ){
        $HostImage->publishRecursive();
    }
}

Any help would be appreciated, is it a permissions issue, a relationship issue?