Essence\Media::set PHP Method

set() public method

Sets the value of the given property.
public set ( string $property, string $value )
$property string Property name.
$value string New value.
    public function set($property, $value)
    {
        $this->_properties[$property] = $value;
        return $this;
    }

Usage Example

Example #1
0
 /**
  *	Builds an HTML code from the given media's properties to fill its
  *	'html' property.
  *
  *	@param Essence\Media $Media A reference to the Media.
  *	@param array $options Options.
  */
 public function complete(Media $Media, array $options = [])
 {
     if ($Media->has('html')) {
         return;
     }
     $title = htmlspecialchars($Media->get('title', $Media->url));
     $description = $Media->has('description') ? htmlspecialchars($Media->description) : $title;
     $options += $this->_defaults;
     $width = $Media->setDefault('width', $options['width']);
     $height = $Media->setDefault('height', $options['height']);
     switch ($Media->type) {
         // builds an <img> tag pointing to the photo
         case 'photo':
             $Media->set('html', sprintf('<img src="%s" alt="%s" width="%d" height="%d" />', $Media->url, $description, $width, $height));
             break;
             // builds an <iframe> tag pointing to the video
         // builds an <iframe> tag pointing to the video
         case 'video':
             $Media->set('html', sprintf('<iframe src="%s" width="%d" height="%d" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen />', $Media->url, $width, $height));
             break;
             // builds an <a> tag pointing to the original resource
         // builds an <a> tag pointing to the original resource
         default:
             $Media->set('html', sprintf('<a href="%s" alt="%s">%s</a>', $Media->url, $description, $title));
             break;
     }
 }
All Usage Examples Of Essence\Media::set