Obtenir l'image principale d'une personne

@param int    $id          ID de la personne
@param string $size        Taille de l'image
@param bool   $showDefault Afficher une image de remplacement si pas d'image ?

@return string URL
331653
public static function getImage($id, $size = "moyen", $showDefault = true, $dimension = array('height'=>200,'width'=>200))
    {
        global $config;
        $req = "
            SELECT idImage
            FROM _personneImage
            WHERE idPersonne = '".mysql_real_escape_string($id)."'
        ";

        $res = $config->connexionBdd->requete($req);
        if ($fetch=mysql_fetch_object($res)) {
            $req = "
                SELECT dateUpload, idHistoriqueImage
                FROM historiqueImage
                WHERE idImage = '".$fetch->idImage."'
            ";
            $res = $config->connexionBdd->requete($req);
            $fetch = mysql_fetch_object($res);
            if (isset($fetch->idHistoriqueImage)) {
                if ($size=="resized") {
                    return "resizeImage.php?id=".$fetch->idHistoriqueImage."&height=".$dimension['height']."&width=".$dimension['width']."";
                }
                return $config->getUrlImage($size).$fetch->dateUpload.'/'.$fetch->idHistoriqueImage.'.jpg';
            }
        }
        if ($showDefault) {
            return "images/avatar/default.jpg";
        }

    }
59764
public function show($id,Request $request)
    {
        if($request->ajax())
        {
            return URL::to('setting/'.$id);
        }

        $setting = Setting::findOrfail($id);
        return view('setting.show',compact('setting'));
    }
492483
public function gravatar($size = 60, $default = 'mm', $rating = 'g')
    {
        $email = $this->email;

        return 'http://www.gravatar.com/avatar/'.md5(strtolower(trim($email)))."?s={$size}&d={$default}&r={$rating}";
    }
1225132
public function resize($id, $size, $disk = true)
    {
        return $this->executeAction($id, ['type' => 'resize', 'size' => $size, 'disk' => $disk ? 'true' : 'false']);
    }
1269296
public function iconAction($fileId, $size = 16)
    {
        $volumeManager = $this->get('phlexible_media_manager.volume_manager');
        $mediaTypeManager = $this->get('phlexible_media_type.media_type_manager');
        $kernel = $this->get('kernel');

        try {
            $volume = $volumeManager->getByFileId($fileId);
        } catch (\Exception $e) {
            throw $this->createNotFoundException($e->getMessage(), $e);
        }

        // TODO get lates file version
        $file = $volume->findFile($fileId);
        $mimeType = $file->getMimeType();
        $mediaType = $mediaTypeManager->findByMimetype($mimeType);
        $icons = $mediaType->getIcons();

        $fileLocator = new FileLocator($kernel);
        $iconPath = $fileLocator->locate($icons[$size]);

        $response = new BinaryFileResponse($iconPath, 200, array('Content-Type' => 'image/gif'));

        return $response;
    }
659052
public function showResource (string $id = null, int $width = 0, int $height = 0, bool $fit = false)
    {
        $storagePath = storage_path ('app/');

        if (is_null ($id))
            return HCLog::error ('R-001', trans ('resources::resources.errors.resource_id_missing'));

        // cache resource for 10 days
        $resource = \Cache::remember($id, 14400, function () use ($id) {
            return HCResources::find ($id);
        });

        if (!$resource)
            return HCLog::error ('R-003', trans ('resources::resources.errors.resource_not_found'));

        if (!Storage::exists ($resource->path))
            HCLog::stop (trans ('resources::resources.errors.resource_not_found_in_storage') . ' : ' . $id);

        $cachePath = generateResourceCacheLocation ($resource->id, $width, $height, $fit) . $resource->extension;

        if (file_exists ($cachePath)) {
            $resource->size = File::size ($cachePath);
            $resource->path = $cachePath;
        } else {

            switch ($resource->mime_type) {
                case 'image/png' :
                case 'image/jpeg' :
                case 'image/jpg' :

                    if ($width != 0 && $height != 0) {

                        createImage ($storagePath . $resource->path, $cachePath, $width, $height, $fit);

                        $resource->size = File::size ($cachePath);
                        $resource->path = $cachePath;
                    } else
                        $resource->path = $storagePath . $resource->path;
                    break;

                case 'video/mp4' :

                    $previewPath     = str_replace ('-', '/', $resource->id);
                    $fullPreviewPath = $storagePath . 'video-previews/' . $previewPath;

                    $cachePath = generateResourceCacheLocation ($previewPath, $width, $height, $fit) . '.jpg';

                    if (file_exists ($cachePath)) {
                        $resource->size      = File::size ($cachePath);
                        $resource->path      = $cachePath;
                        $resource->mime_type = 'image/jpg';
                    } else {

                        if ($width != 0 && $height != 0) {

                            $videoPreview = $fullPreviewPath . '/preview_frame.jpg';

                            //TODO: generate 3-5 previews and take the one with largest size
                            $this->generateVideoPreview ($resource, $storagePath, $previewPath);

                            createImage ($videoPreview, $cachePath, $width, $height, $fit);

                            $resource->size      = File::size ($cachePath);
                            $resource->path      = $cachePath;
                            $resource->mime_type = 'image/jpg';
                        } else
                            $resource->path = $storagePath . $resource->path;
                    }
                    break;

                default:

                    $resource->path = $storagePath . $resource->path;
                    break;
            }
        }

        // Show resource
        header ('Pragma: public');
        header ('Cache-Control: max-age=86400');
        header ('Expires: ' . gmdate ('D, d M Y H:i:s \G\M\T', time () + 86400));
        header ('Content-Length: ' . $resource->size);
        header ('Content-Disposition: inline;filename="' . $resource->original_name . '"');
        header ('Content-Type: ' . $resource->mime_type);
        readfile ($resource->path);

        exit;
    }
400413
public function generateImageUrl($file, $size=null)
	{
		$url = $this->config->get('prefix').'/'.$file;

		if (!is_null($size)) {
			$url .= '?size='.$size;
		}

		return URL::to($url);
	}
1336670
public function show($id,Request $request)
    {
        if($request->ajax())
        {
            return URL::to('package/'.$id);
        }

        $package = Package::findOrfail($id);
        return view('unstarter.package.show',compact('package'));
    }
389247
public function thumbUrl( string $size = 'thumbnail') {
		$size = WP::getImageSize( $size );
		
		return get_avatar_url( $this->ID, ['size' => $size['width'] ] );
	}
89380
public function buildUrl($id, $image, $dimension)
    {
        $url = $this->provide($this->baseUrl, $id, $dimension, $image);
        return $this->normalizeUrl($url);
    }
772343
public function forcedImageDownsize($fail, $id, $size) {
        if(empty($size) || empty($id) || is_array($size)) {
            return $fail;
        }

        $meta = wp_get_attachment_metadata($id);

        if(empty($meta)) {
            return $fail;
        }

        if(!isset($meta['sizes'])) {
            return $fail;
        }

        if(!isset($meta['sizes'][$size])) {
            return $fail;
        }

        $isOffloadS3 = (arrayPath($meta, 's3/provider', null) == 'aws');

        $sizeMeta = $meta['sizes'][$size];
        if(!isset($sizeMeta['s3'])) {
            if ($isOffloadS3) {
                if ($this->fixOffloadS3Meta($id, $meta)) {
                    return $this->forcedImageDownsize($fail, $id, $size);
                } else {
                    return $fail;
                }
            } else {
                return $fail;
            }
        }

        $url = $this->getAttachmentURLFromMeta($sizeMeta);// $sizeMeta['s3']['url'];

        $result = [
            $url,
            $sizeMeta['width'],
            $sizeMeta['height'],
            true
        ];

        return $result;
    }
92440
public function getProfileImage($actor=null, $size=null)
    {

         /** @var CoreManager $coreManager */
        $coreManager =  $this->container->get('core_manager');
        $profileImage = $coreManager->getProfileImage($actor, $size);
        
        return  $profileImage;
    }
97821
public function generateUrl($email, $size = null, $default = null)
    {
        if ($size == null) {
            $size = $this->environment->getConfig()->get(['templates', 'gravatar', 'size']);
        }

        if ($default == null) {
            $default = $this->environment->getConfig()->get(['templates', 'gravatar', 'default']);
        }

        $separator = '?';
        $link      = static::$baseUrl . md5(strtolower(trim($email)));

        if ($size) {
            $link     .= $separator . 's=' . $size;
            $separator = '&';
        }

        if ($default) {
            $link .= $separator . 'd=' . urlencode($default);
        }

        return $link;
    }
836980
public function getUrlImageFromPersonne($idPersonne, $format = 'mini')
    {
        $url="";

        switch ($format) {
            case 'mini':
                $chemin = $this->getUrlImage("mini");
                break;
            case 'moyen':
                $chemin = $this->getUrlImage("moyen");
                break;
            case 'grand':
                $chemin = $this->getUrlImage("grand");
                break;
        }


        // on regarde s'il y a une image de position 1
        $queryAdresse="

				SELECT hi1.idHistoriqueImage as idHistoriqueImage , hi1.idImage as idImage, hi1.nom as nom , hi1.dateUpload as dateUpload , hi1.dateCliche as dateCliche
				FROM historiqueAdresse ha2,historiqueAdresse ha1

				LEFT JOIN _adresseEvenement ae ON ae.idAdresse = ha1.idAdresse
				LEFT JOIN _evenementEvenement ee ON ee.idEvenement = ae.idEvenement
				LEFT JOIN _evenementImage ei ON ei.idEvenement = ee.idEvenementAssocie

				RIGHT JOIN historiqueImage hi1 ON hi1.idImage = ei.idImage
				RIGHT JOIN historiqueImage hi2 ON hi2.idImage = hi1.idImage

				RIGHT JOIN _evenementPersonne ep ON ep.idEvenement = ee.idEvenementAssocie

				WHERE ep.idPersonne='".$idPersonne."'
						AND ha2.idAdresse = ha1.idAdresse
						AND ei.position='1'
						GROUP BY hi1.idImage,ha1.idAdresse, hi1.idHistoriqueImage,ha1.idHistoriqueAdresse
						HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage) AND ha1.idHistoriqueAdresse = max(ha2.idHistoriqueAdresse)
						LIMIT 1
						";

        $resAdresse = $this->connexionBdd->requete($queryAdresse);
        if (mysql_num_rows($resAdresse)==1) {
            $fetchAdresse = mysql_fetch_assoc($resAdresse);
            $url = $chemin.$fetchAdresse['dateUpload'].'/'.$fetchAdresse['idHistoriqueImage'].".jpg";
        } else {
            $queryAdresse="

					SELECT hi1.idHistoriqueImage as idHistoriqueImage , hi1.idImage as idImage, hi1.nom as nom , hi1.dateUpload as dateUpload , hi1.dateCliche as dateCliche
					FROM historiqueAdresse ha2,historiqueAdresse ha1

					LEFT JOIN _adresseEvenement ae ON ae.idAdresse = ha1.idAdresse
					LEFT JOIN _evenementEvenement ee ON ee.idEvenement = ae.idEvenement
					LEFT JOIN _evenementImage ei ON ei.idEvenement = ee.idEvenementAssocie

					RIGHT JOIN historiqueImage hi1 ON hi1.idImage = ei.idImage
					RIGHT JOIN historiqueImage hi2 ON hi2.idImage = hi1.idImage

					RIGHT JOIN _evenementPersonne ep ON ep.idEvenement = ee.idEvenementAssocie

					WHERE ep.idPersonne='".$idPersonne."'
							AND ha2.idAdresse = ha1.idAdresse
							GROUP BY hi1.idImage,ha1.idAdresse, hi1.idHistoriqueImage,ha1.idHistoriqueAdresse
							HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage) AND ha1.idHistoriqueAdresse = max(ha2.idHistoriqueAdresse)
							LIMIT 1
							";
            $resAdresse = $this->connexionBdd->requete($queryAdresse);
            if (mysql_num_rows($resAdresse)>0) {
                $fetchAdresse = mysql_fetch_assoc($resAdresse);
                $url = $chemin.$fetchAdresse['dateUpload'].'/'.$fetchAdresse['idHistoriqueImage'].".jpg";
            } else {
                $url = $this->getUrlImage()."/transparent.gif";
            }
        }
        return $url;
    }
532010
public function inspect(string $id, bool $insertDefaults = false)
    {
        $url = self::BASE_URL.'/'.$id.'?'.http_build_query(['insertDefaults' => $insertDefaults]);

        return $this->curl->get($url);
    }
1263879
public function showAction($id = null)
    {
        $request = $this->getRequest();
        $id = $request->get($this->admin->getIdParameter());

        $object = $this->admin->getObject($id);

        if (!$object) {
            throw $this->createNotFoundException(sprintf('unable to find the object with id: %s', $id));
        }

        $this->checkParentChildAssociation($request, $object);

        $this->admin->checkAccess('show', $object);

        $preResponse = $this->preShow($request, $object);
        if (null !== $preResponse) {
            return $preResponse;
        }

        $this->admin->setSubject($object);

        $fields = $this->admin->getShow();
        \assert($fields instanceof FieldDescriptionCollection);

        // NEXT_MAJOR: replace deprecation with exception
        if (!\is_array($fields->getElements()) || 0 === $fields->count()) {
            @trigger_error(
                'Calling this method without implementing "configureShowFields"'
                .' is not supported since 3.40.0'
                .' and will no longer be possible in 4.0',
                E_USER_DEPRECATED
            );
        }

        // NEXT_MAJOR: Remove this line and use commented line below it instead
        $template = $this->admin->getTemplate('show');
        //$template = $this->templateRegistry->getTemplate('show');

        return $this->renderWithExtraParams($template, [
            'action' => 'show',
            'object' => $object,
            'elements' => $fields,
        ], null);
    }
1032396
public function show($id)
    {
      $user  = $this->users->findOrFail($id);
      return \View::make('admin.users.show', [
        'user'              =>  $user,
        'title'              => 'view',
      ]);
    }