You are here

function _emimage_custom_url_validate_image_helper in Embedded Media Field 6.3

Same name and namespace in other branches
  1. 6 contrib/emimage/providers/custom_url.inc \_emimage_custom_url_validate_image_helper()

Function gets all the information from an image and stores it in an array of 7 elements. It helps to avoid getting php warning if the image is not valid.

Index 0 and 1 contains respectively the width and the height of the image. Index 2 is one of the IMAGETYPE_XXX constants indicating the type of the image. Index 3 is a text string with the correct height="yyy" width="xxx" string that can be used directly in an IMG tag. Index mime is the correspondant MIME type of the image. This information can be used to deliver images with correct the HTTP Content-type header. Index channels will be 3 for RGB pictures and 4 for CMYK pictures. Index bits is the number of bits for each color.

Parameters

$color A hexadecimal value representing a color.:

Return value

A boolean value, true if the image source is valid.

2 calls to _emimage_custom_url_validate_image_helper()
emimage_custom_url_data in contrib/emimage/providers/custom_url.inc
This function will get additional information of the image source input by the end user. It will also use a helper function to validate the source of the image.
emimage_custom_url_extract in contrib/emimage/providers/custom_url.inc
Function uses helper function to validate the source of the image. If the source of the image is validated then its return, otherwise an empty array is returned so that the invoking function emfield_parse_embed() performs its own image source validation.

File

contrib/emimage/providers/custom_url.inc, line 167

Code

function _emimage_custom_url_validate_image_helper($_filename) {
  $_filedata = @getimagesize($_filename);
  if ($_filedata['mime'] != 'image/jpeg' && $_filedata['mime'] != 'image/gif' && $_filedata['mime'] != 'image/png' && $_filedata['mime'] != 'image/bmp') {

    //     form_set_error(
    //       'name',
    //       t('There were problems encountered while processing this image.',
    //       array('%name' => ''))
    //     );
    return false;
  }
  return true;
}