below is used by logo_photo and about_us_photo,
 where only one photo is allowed
548904
def update_photo
      content_tag = params[:content_tag]
      # photo = ContentPhoto.find(params[:id])
      # find would throw error if not found
      photo = ContentPhoto.find_by_id(params[:id])
      unless photo
        if content_tag
          # where photo has never been set before, associated Content will not exist
          content = Content.find_by_key(content_tag) || Content.create({ key: content_tag, tag: 'appearance' })
          photo = ContentPhoto.create
          if content_tag == "logo"
            # TODO: This is a workaround
            # need to have a way of determining content that should only have
            # one photo and enforcing that
            content.content_photos.destroy_all
          end
          content.content_photos.push photo
        end
        # TODO: - handle where no photo or content_tag..
      end
      if params[:file]
        photo.image = params[:file]
      end
      photo.save!
      photo.reload
      render json: photo.to_json
    end
344952
def user_photo_url(user, size):
    """"""
    endpoint, kwargs = user_url_args(user, size)
    return url_for(endpoint, **kwargs)
452109
def _filter_image(self, url):
        ""
        return reduce(lambda f, g: f and g(f), 
        [
            filters.AdblockURLFilter()(url),
            filters.NoImageFilter(),
            filters.SizeImageFilter(),
            filters.MonoImageFilter(),
            filters.FormatImageFilter(),
        ])
917799
def reset!
      self.base_url = nil
      self.secure_base_url = nil
      self.backdrop_sizes = []
      self.logo_sizes = []
      self.logo_sizes = []
      self.poster_sizes = []
      self.profile_sizes = []
      self.still_sizes = []
      self.include_image_language = "en"
      self
    end
744837
def admin_add_photo
      return if !user_is_allowed('media', 'edit')      
            
      x = Media.maximum(:media_order, :conditions => {:mls => params[:mls], :media_type => 'Photo'})
      x = 0 if x.nil?
      
      m = Media.new
      m.id            = Media.maximum(:id) + 1
      m.mls 		  = params[:mls]
      m.date_modified = DateTime.now                  
      m.media_order   = x + 1
      m.media_type 		= 'Photo'
      m.image         = params[:image]
      m.save
      
      render :text => "<script type='text/javascript'>parent.controller.after_image_upload();</script>"                        
    end
551560
function filterImageUrls (elem, urls) {
        var child = elem.firstChild;
        while (child) {
            if (child.tagName == 'IMG') {
                var url = child.src;
                if (urls.indexOf(url) == -1) {
                    urls.push(url);
                }
            }

            filterImageUrls(child, urls);

            child = child.nextSibling;
        }
    }
302592
static function cleanupRegisteredImages()
    {
        $createdImageArray =& $GLOBALS['eZImageCreatedArray'];
        if ( !is_array( $createdImageArray ) )
            return;
        foreach ( array_keys( $createdImageArray ) as $createImageKey )
        {
            $createdImage = $createdImageArray[$createImageKey];
            if ( is_resource( $createdImage ) and get_resource_type( $createdImage ) == 'gd' )
                ImageDestroy( $createdImage );
        }
    }
512416
function createPictures(id, farm, server, secret) {

		var NO_LIMIT = 2048;
		var sizes = [
			{id: 't', max: 100},
			{id: 'm', max: 240},
			{id: 'n', max: 320},
			{id: '', max: 500},
			{id: 'z', max: 640},
			{id: 'c', max: 800},
			{id: 'b', max: 1024},
			{id: 'h', max: 1600},
			{id: 'k', max: 2048},
			{id: 'o', max: NO_LIMIT}
		];

		return sizes.map(function(size) {
			return {
				source: createPhotoUrl(id, farm, server, secret, size.id),

				// Note: this is a guess that's almost certain to be wrong (unless square source)
				width: size.max,
				height: size.max
			};
		});
	}
473564
def _store_post(self, stored_entry, entry=None):
        
        stored_entry.content_type = self.type
        if 1==1 or self.type == 'photos': # ignore type for now
            # is photo
            width = int(entry.width.text)
            height = int(entry.height.text)
            orientation = 'landscape' if width > height else 'portrait'
            max = width if width > height else height
            thumbnails = {}
            sizes = ['72', '144', '288', '480', '512', '800', '1200', '1600']
            for thumb in entry.media.thumbnail:
                size = thumb.width if width > height else thumb.height
                thumbnails['s%s' % size] = {
                    'url': thumb.url,
                    'height': thumb.height,
                    'width': thumb.width
                }
            for size in sizes[3:]:
                big = size
                small = str(int(int(size)/(float(72)/float(thumbnails['s72']['height' if width > height else 'width']))))
                thumbnails['s%s' % size] = {
                    'url': thumbnails['s72']['url'].replace('s72', 's%s' % size),
                    'height': big if height > width else small,
                    'width': small if height > width else big
                }
            url = thumbnails['s144']['url'].replace('s144', 's%s' % max)
            stored_entry.link = self._get_entry_link(entry)
            summarytext = ''
            if entry.summary.text != None:
                summarytext = unicode(entry.summary.text, "utf-8")
            stored_entry.summary = summarytext
            stored_entry.title = unicode(entry.title.text, "utf-8")
            stored_entry.categories = 'photos'
            stored_entry.published = datetime.datetime.strptime(entry.published.text, '%Y-%m-%dT%H:%M:%S.%fZ')
            stored_entry.updated = datetime.datetime.strptime(entry.updated.text, '%Y-%m-%dT%H:%M:%S.%fZ')
            stored_entry.author = entry.albumid.text
            stored_entry.attributes = simplejson.dumps({
                'id': entry.gphoto_id.text,
                'thumbnails': thumbnails,
                'url': url,
                'width': str(width),
                'height': str(height),
                'orientation': orientation
            })
#        elif self.type == 'albums':
#            # is albums
#            summarytext = ''
#            if entry.summary.text != None:
#                summarytext = unicode(entry.summary.text, "utf-8")
#            itemLink = entry.link[1].href
#            stored_entry.name = itemLink[itemLink.rfind('/')+1:]
#            stored_entry.categories = 'albums'
#            stored_entry.title = unicode(entry.title.text, "utf-8")
#            stored_entry.published = datetime.datetime.strptime(entry.published.text, '%Y-%m-%dT%H:%M:%S.%fZ')
#            stored_entry.updated = datetime.datetime.strptime(entry.updated.text, '%Y-%m-%dT%H:%M:%S.%fZ')
#            stored_entry.author = entry.user.text
#            stored_entry.summary = summarytext
#            stored_entry.attributes = simplejson.dumps({
#                'id': entry.gphoto_id.text,
#                'thumbnail': entry.media.thumbnail[0].url,
#        })
        return super(Picasa, self)._store_post(stored_entry)
1099174
private function fixCaptchaImage(){
		
		# Final equired image width must be
		# Last _front_text x position + initial_x
		
		$final_width = $this->_front_text['x'] + $this->_front_text['initial_x'];
		
		# check if to set final width
		if( $this->_image_info['width'] > $final_width )
			$this->_image_info['width'] = $final_width; 
		
		
		$this->_final_image = imagecreatetruecolor( $this->_image_info['width'], $this->_image_info['height'] );
		
		if( function_exists( 'imageantialias' ) )
			imageantialias( $this->_final_image, true );
		
		
		imagecopy(
					$this->_final_image,				# destination image resource to copy into
					$this->_image_resource,				# source image resource to copy from
					0,									# start x position to copy into in destination image
					0,									# start y position to copy into in destination image
					0,									# start x position to copy from in source image
					0,									# start y position to copy from in source image
					$this->_image_info['width'],		# width to copy from source image 
					$this->_image_info['height'] 		# height to copy from source image
				 );
		
		# Removing the first image from memory
		imagedestroy( $this->_image_resource );
		
		# Method End
	}
765019
def delete(resource_group_name, image_name, custom_headers:nil)
      response = delete_async(resource_group_name, image_name, custom_headers:custom_headers).value!
      nil
    end
602169
def image_resources(resource_name, options = {})
      options = {
        path:        "#{resource_name}/:digest(/:size)",
        constraints: { size: /\d+x\d+/ },
        only:        [:show]
      }.merge(options)
      resources resource_name, options do
        get :uncropped, on: :member
        get :original, on: :member
        get :download, on: :member
      end
    end
1016125
def srcset
      return '' unless sources_photos.kind_of? Array
      @srcset ||= source_photos.inject([]) do |res, photo| 
        res << [photo.id, photo.sizing].join(' ')
      end.join(',')
    end
715518
def thumb
      @image = Tandem::Image.find_by_id(params[:id])
      @content = Tandem::Content::Image.new(image: @image)
      respond_to do |format|
        format.html { render layout: nil }# thumb.html.erb
      end
    end
741842
function wireUsePhotoHandlers(){
    
    $usePhoto.bind('click submit', function(e){
       
      if(e.target.id === 'facebook-use-photo'){
        
        // We don't want to show the facebook option, because
        // it is the source of the image.
        $facebookDestination.hide()

        _photoToUse = localStorage.imageToPipe || $('.one-up:visible').find('img')[0].src
        
        closeOneUp()
        
        $stepFourDestinationWrapper.show()

        progressToNextStep($stepThree, function(){

          $stepFour.slideDown(333)

        })

      }

      if(e.target.id === 'twitter-use-photo'){
        
        // We don't want to show the facebook option, because
        // it is the source of the image.
        $twitterDestination.hide()
        
        _photoToUse = localStorage.imageToPipe || $('.one-up:visible').find('img')[0].src
                
        closeOneUp()

        $stepThreeDestinationWrapper.show()
        
        progressToNextStep($stepTwo, function(){

          $stepThree.slideDown(333)

        })

      }


      if(e.target.id === 'url-use-photo'){
        
        _photoToUse = $photoFromUrl.val() || localStorage.imageToPipe
        
        $stepThreeDestinationWrapper.show()
        
        progressToNextStep($stepTwo, function(){

          $stepThree.slideDown(333)

        })

      }
      
      localStorage.imageToPipe = _photoToUse

      console.log(_photoToUse)
      console.log(localStorage.imageToPipe)
      return false

    }) // end bind()
    
  }
1315773
public static function Logo() {
      $Logo = C('Garden.Logo');
      if ($Logo) {
         $Logo = ltrim($Logo, '/');
         // Fix the logo path.
         if (StringBeginsWith($Logo, 'uploads/'))
            $Logo = substr($Logo, strlen('uploads/'));
      }
      $Title = C('Garden.Title', 'Title');
      echo $Logo ? Img(Gdn_Upload::Url($Logo), array('alt' => $Title)) : $Title;
   }
634588
def photo_url(self):
        
        if self.url is not None:
            if self.soup is not None:
                img = self.soup.find('img', class_='Avatar Avatar--l')['src']
                return img.replace('_l', '_r')
            else:
                assert (self.card is not None)
                return PROTOCOL + self.card.img['src'].replace('_xs', '_r')
        else:
            return 'http://pic1.zhimg.com/da8e974dc_r.jpg'