LemonStand Documentation

Db_File

The Db_File class represents a file in the LemonStand database. Usually you need to work with this class when you access a product or category images. Downloadable product files are presented with another class – Shop_ProductFile.

Parent class: Db_ActiveRecord

Class fields

  • $name – a file name
  • $size – size of the file, in bytes
  • $description - the file description
  • $title - the file title

Class methods

  • getThumbnailPath($width, $height, $as_jpeg = true, $params = array()) – creates an image thumbnail and returns its relative URL. The $width and $height parameters could be either integer numbers or the 'auto' word. If you specify an integer number for the width or height, the thumbnail will have the exact width or height value, in pixels. Use the 'auto' word to scale an image dimension proportionally. For example, to generate a thumbnail with fixed width of 100 pixels and proportional height, use the following code:
    $url = $file->getThumbnailPath(100, 'auto');
    The $as_jpeg parameter allows you to generate PNG images with transparency support. By default the parameter value is TRUE and the method generates a JPEG image. Pass the FALSE value to the parameter to generate a PNG image. The $params array allows to pass parameters to image processing modules (which handle the core:onProcessImage event).
  • is_image() - returns TRUE is the file is an image. The function returns TRUE for files with the following extensions: jpeg, jpg, gif, png.
  • getPath() - returns path to the original file relative to the LemonStand installation directory. To get the absolute path to a file use the following code:
    $absolute_path = PATH_APP.$file->getPath();

See also:

Next: Phpr_DateTime
Previous: Db_DataCollection
Return to Reference

Comments

No comments posted so far.

Add your comment

Loading form...