Example #1
0
<?php

add_filter('wpcf_fields_type_image_value_get', 'wpcf_fields_image_value_filter');
add_filter('wpcf_fields_type_image_value_save', 'wpcf_fields_image_value_filter');
add_filter('upload_dir', 'wpcf_fields_image_uploads_realpath');
/*
 * Win specific
 */
if (wpcf_is_windows()) {
    add_filter('update_attached_file', 'wpcf_fields_image_win32_update_attached_file_filter', 10, 2);
}
/**
 * Register data (called automatically).
 * @return type 
 */
function wpcf_fields_image()
{
    return array('id' => 'wpcf-image', 'title' => __('Image', 'wpcf'), 'description' => __('Image', 'wpcf'), 'validate' => array('required'), 'meta_box_js' => array('wpcf-jquery-fields-file' => array('inline' => 'wpcf_fields_file_meta_box_js_inline'), 'wpcf-jquery-fields-image' => array('inline' => 'wpcf_fields_image_meta_box_js_inline')), 'inherited_field_type' => 'file');
}
/**
 * Renders inline JS.
 */
function wpcf_fields_image_meta_box_js_inline()
{
    global $post;
    ?>
    <script type="text/javascript">
        //<![CDATA[
        jQuery(document).ready(function(){
            wpcf_formfield = false;
            jQuery('.wpcf-fields-image-upload-link').live('click', function() {
Example #2
0
<?php

add_filter('wpcf_fields_type_image_value_get', 'wpcf_fields_image_value_filter');
add_filter('wpcf_fields_type_image_value_save', 'wpcf_fields_image_value_filter');
/*
 * Win specific
 * 
 * 'upload_dir' filter added in 1.1.3.3 version
 * 'update_attached_file' added in 1.2 version to fix issues caused by previous filter
 */
if (wpcf_is_windows() && !is_multisite()) {
    //    add_filter( 'upload_dir', 'wpcf_fields_image_uploads_realpath' );
    //    add_filter( 'update_attached_file',
    //            'wpcf_fields_image_win32_update_attached_file_filter', 10, 2 );
}
/**
 * Register data (called automatically).
 * @return type 
 */
function wpcf_fields_image()
{
    return array('id' => 'wpcf-image', 'title' => __('Image', 'wpcf'), 'description' => __('Image', 'wpcf'), 'validate' => array('required'), 'meta_box_js' => array('wpcf-jquery-fields-file' => array('inline' => 'wpcf_fields_file_meta_box_js_inline'), 'wpcf-jquery-fields-image' => array('inline' => 'wpcf_fields_image_meta_box_js_inline')), 'inherited_field_type' => 'file');
}
/**
 * Renders inline JS.
 */
function wpcf_fields_image_meta_box_js_inline()
{
    global $post;
    ?>
    <script type="text/javascript">