JeroenDesloovere\VCard\VCard::addPhoto PHP Method

addPhoto() public method

Add Photo
public addPhoto ( string $url, boolean $include = true )
$url string image url or filename
$include boolean Include the image in our vcard?
    public function addPhoto($url, $include = true)
    {
        $this->addMedia('PHOTO', $url, $include, 'photo');
        return $this;
    }

Usage Example

 /**
  * Returns a vcard for a profile
  * @param $profile
  * @param $includePhoto
  * @return VCard
  */
 public function getVCard($profile, $includePhoto)
 {
     $vcard = new VCard();
     $vcard->addName($profile['lastName'], $profile['firstName'])->addCompany($profile['company'])->addAddress('', '', $profile['address']['street'], $profile['address']['city'], $profile['address']['region'], $profile['address']['zip'], $profile['address']['country'])->addEmail($profile['email'])->addURL($profile['url'])->addPhoneNumber($profile['phone']['work'], 'WORK')->addPhoneNumber($profile['phone']['mobile'], 'CELL')->addJobtitle($profile['jobTitle']);
     // Add photo
     if ($profile['photo'] != null) {
         $photoUri = null;
         if ($includePhoto) {
             // Generate filesystem URI
             $webDir = $this->kernelRootDir . '/../web/';
             $photoUri = $webDir . $profile['photo'];
         } else {
             // Generate absolute public URI
             $photoUri = $this->request->getUriForPath('/' . $profile['photo']);
         }
         $vcard->addPhoto($photoUri, $includePhoto);
     }
     return $vcard;
 }
All Usage Examples Of JeroenDesloovere\VCard\VCard::addPhoto