I'm using Zend_Form as part of a simple signup process. In part 1 of 2 the user is able to upload a number of images. In part 2 - for each one of these images - I ask the user to add further details - an additional 4 text fields grouped together using addDisplayGroup. Within each display group I want to display a thumbnail of the uploaded image. I have generated these thumbs and all the processing is complete but i'm unsure what the best approach is for displaying the image within the relevant section. I guess its possible to create a custom form element to display this but somehow this feels like overkill considering the image is purely being used for display purposes. I also dont really want to replace $this->form->render() with a manual outputting of the form. Could this be achieved with a decorator maybe? I'm still fairly new to ZF so any ideas would be much appreciated.
Thanks.
You would use a custom decorator in your decorator stack for the display group. Or you could use the HtmlTag decorator.
http://framework.zend.com/manual/en/zend.form.forms.html#zend.form.forms.displaygroups
there is an excelent example for an Custom image "Preview" Element:
Zend Form with Image
Or try the Zend_Form_Element_Image shipped with the Framework
Zend Form Element Image
Related
I'm looking for a solution to have this kind of functionality to work on silverstripe:
http://papermashup.com/demos/php-gd-image-and-text/
Basically I would like to make an object on the back (page) with uploadable fonts and base image and then on the front end (for any user) I would like to have a form with font chooser (from fonts I've uploaded for this particular page) - finally it will generate the image with some text.
I can't find any solution for SilverStripe.
This sounds rather like you're asking for help with a particular solution, and not with a specific issue that you're having.
What have you tried so far? Did you check https://addons.silverstripe.org? What did you find?
What you're asking is totally possible, and off the top of my head requires a a custom subclass of GDBackend which will interact with GD directly, a custom Controller comprising a single public method who's logic calls your custom GD logic to generate the image, and some basic jQuery+AJAX to POST the form-field values into your controller.
I use Simple HTML DOM library in my Drupal custom module to do a task in my project.
The task simply is imitating the Facebook action, when we paste an article url, FB scrap the url and return back with part of the article as a description and an image.
My question is, what is the used algorithm to pick the first part of the article between a lot of <p> tags and also pick the right picture between all the pics in the page!
I know that FB use a :OG tag, but I need to develop an algorithm which pick these info if the OG tag is not there.
Thank you guys for support and have a nice day.
Regards.
I think with the image it is the dimensions of the image. Th takes the first image with more than say 100x100 pixels or so.
With the text it might be something similar. Strip the inline HTML tags, get the first block element text (or maybe just paragraphs) and there you go.
I just need a bit of advice on what direction to go with something I am creating.
It is a simple php based webpage for our sports and social members in our office, allowing them to create, edit, view and delete events for all members to see. Events like day trips, bbq's and all kinds of things like that.
So far I have it all working as I would like, other than one thing, being the event logos.
At present, the events are all stored in a mysql database, in one table, with a column for every aspect of the event; time, date, price, venue etc etc.
I also have two columns for the event logos, one for the venue logo, and one for the general event logo.
What I need advice on, is the best way to create a page that allows a user to upload an image to the server, browse the images already uploaded, select one, and have it's file path entered into a text input when creating the event.
Could someone offer their suggestions on the best way to go about this, or offer an alternative method for selecting and inputting a logo for the event?
Thanks
The Uploadify jQuery plugin works really well for batch and/or AJAX uploads. The way I'd handle your situation would be this:
Show all images on the same page with the form, and give each image a related radio button with the image path as the button's value, so the user simply checks the image they want to use,
If the user wants to upload images, use the Uploadify plugin and it's AJAX callback functions to dynamically populate the existing list of radio buttons.
The comment I made on your question, asking wether you store images (or their file paths) was because I think it would be much easier (and cleaner) for you to retrieve a list of uploaded images by querying a database. Personally, I don't store images in a database, only their file paths, and use PHP to handle any images that need to be deleted or moved. It's easier to assing images to other entities (especially in many-to-many relationships) that way.
If you don't want to store images' data in a separate table, I guess you'd have to use PHP file system functions to get a list of files already uploaded (glob comes to mind, although there could be better functions or this).
EDIT:
There is also a very good AJAX file browser plugin - ckFinder, but I have very little experience with it and can't really comment on its workflow, but if you find it to be a more elegant solution, you should try it out.
if i could understand your question you want to associate the image with the event i.e tag the image with the event right ??
you can use jquery's attr() function to grab the src of img and put it in input field
I ended up storing the images in the database itself.
Saved some hassle on the file path side of things.
I would like to implement a RTE (Rich Text Editor) with the ability to upload images anywhere inside the text. My aim is to create an "add / edit news article" page, where the client can write a story with images.
I am good at PHP and Javascript programming, so I am looking for help about methods of implementing this. Do I create a custom button in this RTE to insert a previously uploaded image or some other way? How do I display those images for the user to choose? Etc.
Bonus points for:
Multiple files upload: the ability for the client to just select e.g. 10 images that are relevant to this story.
Uses some method other than Flash as a default for upload.
Uses jQuery as I use it a lot.
RTE is very lightweight. I don't care if the client has to know a few things (like markdown or something similar), I just don't like bloated RTEs.
Uses new technologies, like HTML5 and / or CSS3.
Let me clarify a few things. I know a few Javascript RTEs and have also used them in several CMSs. So I don't need links to these, I can Google "javascript RTE" myself :). However, something like #hakre said is useful as he pointed out how extensible CKEditor is, which I was not fully aware.
To give an example of the answer I'm looking for: "you can do this with CKEditor, upload images asynchronously with jquery-html5-upload, save all uploaded image filename in a Javascript array, create a new button inside CKEditor with a custom click handler, which displays an overlay with Fancybox and you show all the images (you have filenames stored in an array), user clicks an image and you insert html into the editor".
Something like that but better :) (or should I say accurate).
Anything in here that meets with your reqs? http://ckeditor.com/developer-features
You taken a look at TinyMCEor CKEditor?
The "fake answer" you gave yourself is quite accurate. You would need a RTE editor that supports custom functionality.
The logistics would go along these lines:
User presses a button
An empty div is appended to the input with a unique id
An image uploader popup will open, with pointers to the new div
A combination of jQuery / AJAX / PHP will allow the user to upload a file within the page
The filename is returned after the upload process and inserted in the originally appended div
If you are looking for the specific code for each of these steps, I would recommend finding some tutorials as this isn't something that we can write some fast example code for.
hi
I have some jpg images in MySQL table.
can we show these images with Zend_Form_Element_Image
Could someone please help me by providing sample code?
Sorry i can't provide a working example but here are some useful infos straight from the docs.
Zend_Form_Element_Image
Image elements use the Image Decorator for rendering, in addition to the standard Errors, HtmlTag, and Label decorators.
Zend_Form_Decorator_Image
By default, the decorator uses the element's src property, which can be set with the setImage() method, as the image source.
====
As i understand, first you need to set up an url (controller) which displaying the image from the db then you can add this url as a parameter to setImage()