How to generate thumbnails with Dropzone when using the basic way

时间:2017-06-15 09:28:22

标签: symfony dropzone.js

I'm creating a Symfony 3 CRM for a property database, and I'm implementing DropZone for property image uploads. I've looked around for the answer to my question, but the solutions just say to use createThumbnailFromUrl which is all well and good, but I'm just using Dropzone using the easy method, like so:

<div id="dropzone">
    <form action="{{ oneup_uploader_endpoint('property_images') }}" class="dropzone">
        <input type="hidden" value="{{ property_id }}" name="id" />
    </form>
</div>

I'm using oneup_uploader to actual upload the files, and then after it does this, I use a renamer class to put the image into a folder using the aforementioned property_id:

public function name(FileInterface $file)
{
    $propertyId = $_REQUEST['id'];

    return sprintf('%s/%s.%s',
        $propertyId,
        uniqid(),
        $file->getExtension()
    );
}

Which generates a random file name under a directory using the property ID.

Since there is no actual initialisation and I'm only using the dropzone.js from the site, I don't know how to create and name thumbnails. I need to generate cropped squares for the listings, but I am unsure where to do this - would this need to be done in the PHP as well, after the renaming happens? Or do I need to completely rethink the way I'm implementing Dropzone? Any help appreciated.

EDIT: Now implementing the stojg/crop bundle for Symfony to manually create thumbnails onUpload().

0 个答案:

没有答案
相关问题