Support » Plugin: Front-end Editor » [Plugin: Front-end Editor] new simple_fields_editable_image field problems

  • Resolved youngmicroserf

    (@youngmicroserf)


    Hi Scribu,

    I’ve been trying for hours to extend the editable_image field function so it can work with the file selector of the simple fields custom field UI plugin. Bascially, this involves saving the attachment ID of the newly selected image into the respective postmeta field when the “change image” button is clicked.

    So I’ve been experimenting with your developer guide for new editable fields, but with limited success so far. I’m failing to pass new “data-“-elements (like the post_id and the postmeta key) to the “wrap”-function for some reason. I must be doing something wrong, apparently.

    This is my field description –

    register_fronted_field('simple_field_editable_image', array(
            'class' => 'sf_FEE_Field_Image',
            'title' => 'Simple Fields Editable Image',
            'type' => 'image',
            'argc' => 5
        ));

    this is my template function –

    function sf_editable_image( $post_id, $sfid, $sfvalue, $key, $default_url, $extra_attr = '', $echo = true ) {...}

    in sf_FEE_Field_Image, the wrapper function is

    function wrap( $img, $post_id, $sfid, $sfvalue, $key  ) {
            if ( !$this->check() )
                return $img;
    
            return parent::wrap( $img, compact( 'post_id', 'sfid', 'sfvalue', 'key' ) );
        }

    Problem is, with this code, I get a JS post in which the keys are the first two arguments of the list in the wrap function, but with the values used by the Fee_Field_Image class (key and URL).

    data[post_id]	111
    data[sfid]	http://server.tld/wordpress/wp-content/uploads/2010/09/test.jpg

    I’d be grateful for a suggestion about what I’m doing wrong.

    I’d also wondering if there is a simple way of modifying the JS used via functions.php? So far, I had to modify editor.dev.js so the post would return the attachment ID of the newly picked attachment.

    Thanks for any help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author scribu

    (@scribu)

    I think the problem is exactly in the sf_editable_image(), which you didn’t paste here. 🙂

    Ha, yeah, thanks for pointing me there.

    It was a problem with assigning the values to the filter. So now it works perfectly, this is working out very nicely, changes in the front are mirrored in the backend’s file selector 🙂 But as for the JS – if I were to use another type than image, say

    fieldTypes['sf_image_base'] = fieldTypes['base'].extend({...});

    for this so I could copy my modifications somewhere else – how would I hook the new JS into the plugin?

    Plugin Author scribu

    (@scribu)

    Like this:

    function extra_fee_js_field() {
    ?>
    <script type="text/javascript">
    FrontEndEditor.fieldTypes['sf_image_base'] = FrontEndEditor.fieldTypes['base'].extend({
      // code
    });
    </script>
    <?php
    }
    add_action('front_end_editor_loaded', 'extra_fee_js_field');

    Great! Thanks for all the help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Front-end Editor] new simple_fields_editable_image field problems’ is closed to new replies.