Title: Change a function in file.php
Last modified: November 1, 2018

---

# Change a function in file.php

 *  [deathsueco](https://wordpress.org/support/users/deathsueco/)
 * (@deathsueco)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/change-a-function-in-file-php/)
 * 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 .’](https://wordpress.org/support/topic/change-a-function-in-file-php/&apos;. $file_url .&apos;?output_format=md)‘;}}
 *  // 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 7 years, 6 months ago by [deathsueco](https://wordpress.org/support/users/deathsueco/).
    -  This topic was modified 7 years, 6 months ago by [deathsueco](https://wordpress.org/support/users/deathsueco/).

The topic ‘Change a function in file.php’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-field-suite.svg)
 * [Custom Field Suite](https://wordpress.org/plugins/custom-field-suite/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-field-suite/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-field-suite/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-field-suite/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-field-suite/reviews/)

## Tags

 * [file.php](https://wordpress.org/support/topic-tag/file-php/)

 * 0 replies
 * 1 participant
 * Last reply from: [deathsueco](https://wordpress.org/support/users/deathsueco/)
 * Last activity: [7 years, 6 months ago](https://wordpress.org/support/topic/change-a-function-in-file-php/)
 * Status: not resolved