Hello,
I’m building an add-on for EE2. I have the big picture in mind and the different steps of the project defined, but I wondered if my ideas were the best ones for leading this mini-project.
My aim is to dev a Fieldtype add-on : it would extend the default File Fieldtype, but add a functionality. In the CP, the admin would be able to force the user (publisher) to crop the uploaded image with a fixed square (which would be defined in the settings). It could be interesting in terms of design. If the user/client doesn’t know how to crop an image on his computer (it happens…) or is to forget to go the the File Manager and select the file and crop it and save it …
As I said, I chose a Fieldtype object, it seemed logic to me. The image with the crop area would pop-up using jQuery (so the cp_js_end hook) and I found interesting existing ways to do that.
Then the way the EE saves the changes, I still don’t know. I’m thinking of these steps : 1 - uploading and keeping the original pic. 2 - do the crop on a second file 3 - save the two paths and maybe other stuff like html pre and post processing, etc…
Actually I read the Fieldtype Development topic, and found many ways to interact with data being saved using post_save() or something else.
I’d like to have opinions/thoughts/comments/criticisms !!!
Thanks for your time 😊
Moved to Development and Programming by Moderator
yep, that’s better, i didn’t see this !
Actually, as I’m using a large part of the features of the File Fieldtype, maybe it’s better to build an extension, with settings. But will it be easy to modify the behavior of File Fieldtype (on admin side, add more settings for crop, etc…) ?
Hi Maxime,
Are you sure you need a new add-on? It seems that the functionality you need is quite similar to the functionality of Subdir Upload fieldtype. It has rich set of options and it can crop image of the needed size and it can output both path of original image and that of cropped one.
Hi Laisvunas,
Thanks for the tip but the functionalities of this add-on are not exactly what I’m looking for. Let me express myself in a better way. When the client is filling the publish form and there is a File Fieldtype or a New Fieldtype, when he wants to upload a picture, a (jQuery) pop-up comes and displays the uploaded file with a crop area (predefined by the admin when he added the field).
Is it clear enough ? I tried to find addons like this but without success….
So my wonders are : is it possible to create an extension to make these tasks ? which hooks would I have to use ?
I keep thinking on the subject…
No the idea is to make the user crop : when you upload a picture, you don’t want an automatic device deciding for you the area of the crop. The user clearly wants to define the crop area. It’s not too hard to make the popup, since jQuery modules exists.
If I want to do it inside of the form, how do I make the user select the area ? would I still use jQuery to make the upload and then display the uploaded image into the form (which is the same as I planned to do, except that there is no popup 😊) or would I build a second step in the publish form processing (is it possible though?)?
what do you mean ? I found several ways in jQuery (maybe +PHP) to do the trick, the only thing I have to do is to integrate this with EE. Settings are not a problem at all. The way it interacts with the database depends on the type of addon. If it’s an extension or a fieldtype… I don’t know exactly were I am going but I am walking!!!
If you know free addons which are close to my aim, I’ll have a look at the code. But I will take time to define the several steps of the dev process. For now, the extension seems the best way to me to build this feature. It would save my time concerning the manipulation of the image path… Then, to access the crop file in my templates, I could add some params to the {field} to chose either the original file or the cropped file.
thanks for help, I’m really open to everyone’s suggestions (even if it is to buy an addon ^^)
the only thing I have to do is to integrate this with EE
This integration is not trivial, and it’s not for the fainthearted. That’s what I meant. You will need to write the script which most probably will exceed 1000 lines of PHP and will take a month or more full-time work. For comparison - Subdir Upload fieldtype’s main file is more than 2000 lines of PHP. If you have no experience in writing EE add-ons, then it would be more wise at first to create a couple of semi-trivial add-ons of different types and then to proceed to more ambitious projects.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.