• Hi everybody!!

    Maybe it’s a noobie question but i am trying to change the function called

    function html( $field ) that is placed in \plugins\custom-field-suite\includes\fields\file.php. Because of size limitations, i have deleted some of the 250×250 images from uploads folder and the page is sending lots of 404 errors to server. I want to check if the image exists or not. Something like this…

    function html( $field ) {
    $file_url = $field->value;

    if ( ctype_digit( $field->value ) ) {
    if ( wp_attachment_is_image( $field->value ) ) {
    $file_url = wp_get_attachment_image_src( $field->value );

    $headers = get_headers($file_url[0], 1);
    if (strpos($headers[‘Content-Type’], ‘image/’) !== false) {
    $file_url = ‘‘;
    } else {
    $file_url = ”;
    }

    /*
    $file_url = ‘‘;
    */
    }
    else
    {
    $file_url = wp_get_attachment_url( $field->value );
    $filename = substr( $file_url, strrpos( $file_url, ‘/’ ) + 1 );
    $file_url = ‘‘. $filename .’‘;
    }
    }

    // CSS logic for “Add” / “Remove” buttons
    $css = empty( $field->value ) ? array( ”, ‘ hidden’ ) : array( ‘ hidden’, ” );
    ?>
    <span class=”file_url”><?php echo $file_url; ?></span>
    <input type=”button” class=”media button add<?php echo $css[0]; ?>” value=”<?php _e( ‘Add File’, ‘cfs’ ); ?>” />
    <input type=”button” class=”media button remove<?php echo $css[1]; ?>” value=”<?php _e( ‘Remove’, ‘cfs’ ); ?>” />
    <input type=”hidden” name=”<?php echo $field->input_name; ?>” class=”file_value” value=”<?php echo $field->value; ?>” />
    <?php
    }

    Unfortunedly this also sends 404 errors to server. Any idea of how to do it?

    Other question …. Could i do it in my functions.php file of my child theme? I also try to put the entire php file under my child theme structure but is not working. Only change original file works for me.

    Thanks in advance!!!!

    • This topic was modified 6 years, 1 month ago by deathsueco.
    • This topic was modified 6 years, 1 month ago by deathsueco.
  • The topic ‘Change a function in file.php’ is closed to new replies.