[Plugin: Front-end Editor] Edit image-attatchments
-
Hello,
I’m using attatched images in a Custom Post Type outside of the the_content tag. Is there a way to edit them through the front-end-editor Plugin?
There is already a class for post thumbnails. Maybe that can be modified?Thanks, Jan
-
What exactly would you like to be able to do?
I’m using wp_get_attachment_image to show a image in a single-template (within the loop, image is an attatchment of the current post).
The author must be able to change this image.I took a closer look at the FEE_Field_Thumbnail Class and realized, that the thumbnail is a simple custom field containing the image(Attachment)-ID.
I could save my images (they are limited to 3) as Attachment-IDs in three Customfields. What I need is: the function for Thumbnails (you already have) for a custom field.
Example:
The custom field _xyz_image contains the Attachment-ID of an image. If I call e.g. editable_custom_attachment( $post->ID, ‘_xyz_image’, ‘image’, ‘thumbnail’ ) it shows the attachment in thumbnail size. On double click it opens the thickbox to upload/change the Image saved in custom field _xyz_image.I hope this was understandable. I’ve tried it on my own, but I had difficulties to understand the complete Code.
By searching for an example, I’ve found this link: http://scribu.net/wordpress/front-end-editor/developer-guide.html but the Site doesn’t exist any more, right?Maybe you can point me the right direction.
Thanks, Jan
Argh! Hours of working, but I still don’t get it and deadlines coming nearer and nearer…
I need to accomplish two things:
1. Change a image like described above.
2. And write a Field for custom Data of a Plugin (stored in a db-table).Using “fee_register_field” I register my own field, right? And thats, what I use in apply_filters, right?
myFieldClass::get() is used to get the actual data.
I still don’t really understand how the content is wrapped and how Data like the $key is handled between AJAX and the myFieldClass.Please help me a bit.
I’ve solved the Point 2 by using a custom field and the action-hook “updated_post_meta”.
But I still have no solution for my Images: I need the same function like changing the posts thumbnail. Just for another custom field.
I need the same function like changing the posts thumbnail. Just for another custom field.
Then make a class that extends from FEE_Field_Thumbnail (found in fields/post.php).
You will need to emulate the WordPress ‘post_thumbnail_html’ filter with your own.
Finally, register your filter with your custom class. See fee_register_defaults() in front-end-editor.php
Ok, that helped me a lot. Now I understand, how it works.
But I have one issue: The Image is wrapped and if I doubleclick it, I get the thickbox etc. But if I click on “Attach” the thickbox doesn’t disappear and the image isn’t changed.
Can you help me one more time, please?These are my class and function:
// Handles the post thumbnail class FEE_Field_Img_1 extends FEE_Field_Thumbnail { function wrap( $html, $post_id, $post_thumbnail_id, $size ) { if ( !$post_id = $this->_get_id( $post_id, false ) ) return $html; return FEE_Field_Base::wrap( $html, compact( 'post_id', 'size' ) ); } function get( $data ) { extract( $data ); return get_post_meta( $post_id, '_fit_profile_img_1', true ); } function save( $data, $thumbnail_id ) { extract( $data ); if ( -1 == $thumbnail_id ) { delete_post_meta( $post_id, '_fit_profile_img_1' ); return -1; } update_post_meta( $post_id, '_fit_profile_img_1', $thumbnail_id ); list( $url ) = image_downsize( $thumbnail_id, $size ); return $url; } } function fit_get_img_1( $post_id = NULL, $size = 'post-thumbnail', $attr = '' ) { global $id; $post_id = ( NULL === $post_id ) ? $id : $post_id; $post_thumbnail_id = get_post_meta( $post_id, '_fit_profile_img_1', true ); if ( $post_thumbnail_id ) { $html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr ); } else { $html = ''; } return apply_filters( 'editable_img_1', $html, $post_id, $post_thumbnail_id, $size ); }
And this is, what I register:
'editable_img_1' => array( 'title' => __( 'Profile image 1', 'front-end-editor' ), 'class' => 'FEE_Field_Img_1', 'type' => 'thumbnail', 'argc' => 4 )
No Idea?
Please help me a bit.
The Image is wrapped and if I doubleclick it, I get the thickbox etc. But if I click on “Attach” the thickbox doesn’t disappear and the image isn’t changed
I have this same issue.
I’m trying to change the thumbnail when on single template for a custom post type.
Thickbox opens, lets me upload the picture, but clicking the button to attach the uploaded image the image does not apply:
1) old image is deleted
2) new image has “null” as src (<img src=”null” />)INSTEAD, in the thickbox window, if I go into library tab, the Attach button works fine and changes the image as it should.
Now if for me it could be ok, I have a lot of contributors on the site and I would like to hide the “library” tab (using css) because I don’t want them to see all images uploaded on media, but if I hide that library tab they would not be able to change thumbnails.
anyone else has this issue?
- The topic ‘[Plugin: Front-end Editor] Edit image-attatchments’ is closed to new replies.