The "Size of photos" select is always reset to "Square" when saving blocks.

Comments

dewolfe001’s picture

There are several problems in play. Here is what I did to fix this issues:

on block\flickr_block.module:
(after

    // remove the large and original sizes
    $size_options = flickr_photo_sizes();
    unset($size_options['b']);
    unset($size_options['o']);

)
add this:

	foreach ($size_options as $key=>$value) {
	    $choice = new stdClass();
        $choice->option = array($key => $value['label'].' - '. $value['description']);
        $new_size_options[] = $choice;	
	}

	$size_options = $new_size_options;

(after

      variable_set("flickr_block_{$delta}_user_id", $edit["flickr_block_{$delta}_user_id"]);
      variable_set("flickr_block_{$delta}_show_n", $edit["flickr_block_{$delta}_show_n"]);

)
add this:

      variable_set("flickr_block_{$delta}_size", $edit["flickr_block_{$delta}_size"]);

on flickr.inc:
(find

  if ($size == 's') {
    $attributes['height'] = $attributes['width'] = 75;
    $img_url = flickr_photo_img($photo, $size);
  }
  else {
    $response = flickr_photo_get_sizes($id);
    if ($response) {
      foreach ($response['sizes']['size'] as $imagesize) {
        if ($imagesize['label'] == $sizes[$size]['label']) {
          break;
        }
      }
      if (isset($imagesize)) {
        $img_url = $imagesize['source'];
        $attributes['height'] = $imagesize['height'];
        $attributes['width'] = $imagesize['width'];
      }
    }
    else {
      $img_url = flickr_photo_img($photo, $size, $format);
    }
  }

) replace it with this:

  switch ($size) {
    case 's':
		$attributes['height'] = $attributes['width'] = 75;
		$img_url = flickr_photo_img($photo, $size);
		break;
    case 't':
		$attributes['height'] = $attributes['width'] = 100;
		$img_url = flickr_photo_img($photo, $size);
		break;
    case 'm':
		$attributes['height'] = $attributes['width'] = 240;
		$img_url = flickr_photo_img($photo, $size);
		break;
    case '-': case 'l':
		$attributes['height'] = $attributes['width'] = 500;
		$img_url = flickr_photo_img($photo, $size);
		break;
	default:
		$response = flickr_photo_get_sizes($id);
		if ($response) {
		  foreach ($response['sizes']['size'] as $imagesize) {
			if ($imagesize['label'] == $sizes[$size]['label']) {
			  break;
			}
		  }
		  if (isset($imagesize)) {
			$img_url = $imagesize['source'];
			$attributes['height'] = $imagesize['height'];
			$attributes['width'] = $imagesize['width'];
		  }
		}
		else {
		  $img_url = flickr_photo_img($photo, $size, $format);
		}
  }

I tried this on my site: http://www.thosedewolfes.com and http://www.thosedewolfes.com/?q=photos and it seems to work for me.

drewish’s picture

Status: Active » Fixed

this has been fixed.

Anonymous’s picture

Status: Fixed » Closed (fixed)