Return a photo as a response.

@param int    $photoId
@param string $size

@return \Illuminate\Http\Response
517165
public function getPhoto($photoId, $size = 'large')
    {
        $photo = Photo::findOrFail($photoId);

        switch ($size) {
            case 'large':
                return response()->download(storage_path().'/app/'.$photo->pathLarge);
            case 'small':
                return response()->download(storage_path().'/app/'.$photo->pathSmall);
        }

        abort(404);
    }
845317
public static function image($itemId, $size)
    {
        if(has_post_thumbnail($itemId))
        {
            return wp_get_attachment_image_src(
                get_post_thumbnail_id($itemId), $size
            )[0];
        }

        return false;
    }
394800
public function getThumbnail($size = self::IMG_SIZE_THUMBNAIL)
    {
        /*
         * Define a func for to get the attachment-src from the post_id
         */
        $getSrc = function ($_id) use ($size) {
            $imageObject = wp_get_attachment_image_src(get_post_thumbnail_id($_id), $size);
            if (empty($imageObject)) {
                return false;
            }
            return $imageObject[0];
        };

        if (($imageObject = $getSrc($this->ID))) {
            return $imageObject;
        }
        // if they aren't, we get the first img from the post, and let it as thumbnail
        preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $this->post_content, $matches);
        $src = isset($matches[1]) ? $matches[1] : '';
        $attachmentId = Utils::getAttachmentIdFromUrl($src);
        // try to set the first img as thumbnail
        set_post_thumbnail($this->ID, $attachmentId);
        /*
         * In case we found it return the img src from wp_get_attachment_image_src()
         * Othercase return the raw source
         */
        if (($imageObject = $getSrc($this->ID))) {
            return $imageObject;
        }

        return $src;
    }
830837
private function resizeImage($request, $photoKey, $thumbnail)
    {
        $newRequest = $this->getSizeParameters($request);

        if ( $newRequest['width'][$photoKey] == 0 ) {
            $thumbnail = $request->has('crop_type') ? $this->getCropTypeSize($thumbnail,$request->get('crop_type')) : $thumbnail;
            $this->image->fit($thumbnail['width'], $thumbnail['height'], function($constraint)
            {
                $constraint->aspectRatio();
//                $constraint->upsize();
            });
            return;
        }
        $this->image->crop($newRequest['width'][$photoKey], $newRequest['height'][$photoKey], $newRequest['x'][$photoKey], $newRequest['y'][$photoKey])
            ->resize($thumbnail['width'], $thumbnail['height'], function($constraint)
            {
                $constraint->aspectRatio();
            });
    }
743556
public function thumbnail($size = null, $attr = null)
    {
        return get_the_post_thumbnail($this->id(), $size, $attr);
    }
865108
public function getSubImage(Point $position, Dimensions $size) {
		return new Image(null, $this->image, $position, $size);
	}
1369109
public function show($id)
    {
        $documentRepository = new DocumentRepository();
        $file = $documentRepository->getFile( $id );
        return response( $file, 200 )->header( 'Content-Type', 'image/jpeg' );
    }
89343
public function thumbnail($size = null)
    {
        $size = ($size) ? $size : $this->config->get('images.size');

        if ($id = $this->thumbnailId) {
            return new Image($id, $size);
        }
    }
565026
public function findImageSize($sizeName)
	{
		if ($this->imageSizes->containsKey($sizeName)) {
			return $this->imageSizes->get($sizeName);
		} else {
			return null;
		}
	}
1255322
public function featured_image_url( $size = 'thumbnail', $default = '' ) {
		$featured_image = \get_the_post_thumbnail_url( $this->id(), $size );
		return ( false !== $featured_image ) ? $featured_image : $default;
	}
280656
private function buildPresetsUI($image_id, $size) {
		$presets = get_option('ilab-imgix-presets');
		if(!$presets) {
			$presets = [];
		}

		$sizePresets = get_option('ilab-imgix-size-presets');
		if(!$sizePresets) {
			$sizePresets = [];
		}

		$presetsUI = [];
		foreach($presets as $pkey => $pinfo) {
			$default_for = '';
			foreach($sizePresets as $psize => $psizePreset) {
				if($psizePreset == $pkey) {
					$default_for = $psize;
					break;
				}
			}

			$psettings = $pinfo['settings'];
			foreach($this->paramPropsByType['media-chooser'] as $mkey => $minfo) {
				if(isset($psettings[$mkey])) {
					if(!empty($psettings[$mkey])) {
						$psettings[$mkey.'_url'] = wp_get_attachment_url($psettings[$mkey]);
					}
				}
			}

			$presetsUI[$pkey] = [
				'title' => $pinfo['title'],
				'default_for' => $default_for,
				'settings' => $psettings
			];
		}

		return $presetsUI;
	}
1169509
function getPhotoById($photoId) {
        $photos = new Zend_Gdata_Photos($this->client);
        $query = new Zend_Gdata_Photos_PhotoQuery();
        $query->setUser($this->user);
        $query->setAlbumId($this->album);
        $query->setPhotoId($photoId);
        $query = $query->getQueryUrl() . "?kind=comment,tag&imgmax=1600";
        
        $photoFeed = $photos->getPhotoFeed($query);
        return $photoFeed;
    }
717573
public function thumbnail($size = 'post-thumbnail', $attr = '', $post = null)
    {
        if (is_null($post)) {
            $post = $this->id();
        }

        return get_the_post_thumbnail($post, $size, $attr);
    }
1073663
public function imageGetIntermediateSize($data, $post_id, $size) {
	    $result = $this->buildImgixImage($post_id, $size);

	    if (is_array($result) && !empty($result)) {
            $data['url'] = $result[0];
        }

		return $data;
	}
859304
public static function getAvatarById($userId, $size = self::AVATAR_MIDDLE)
    {
        $user = User::findOne(['id' => $userId]);
        if ($user) {
            return self::getAvatar($user, $size);
        }
        return '';
    }
1225132
public function resize($id, $size, $disk = true)
    {
        return $this->executeAction($id, ['type' => 'resize', 'size' => $size, 'disk' => $disk ? 'true' : 'false']);
    }
1301721
protected function getAvatarUrl( $id, $size ) {
		$attachments_fallback_chain = $this->getAttachmentFallbackChain( $id );

		foreach ( $attachments_fallback_chain as $attachment_id ) {
			$image = wp_get_attachment_image_src( $attachment_id, $size );
			if ( ! empty( $image ) ) {
				return $image[0];
			}
		}

		return null;
	}