       if imagepicker_option.value() in @selected_values()
         imagepicker_option.option.prop("selected", false)
       else
-        imagepicker_option.option.prop("selected", true)
+        if @limit > 0 && (@selected_values().length < @limit)
+          imagepicker_option.option.prop("selected", true)
+        else
+          if type(@limit_reached) is "function"
+            @limit_reached.call();
     else
       if @has_implicit_blanks() && imagepicker_option.is_selected()
         @select.val("")

  constructor: (select_element, @opts={}) ->
    @select         = jQuery(select_element)
    @multiple       = @select.attr("multiple") == "multiple"
    @build_and_append_picker()

  build_and_append_picker: () ->

    changed:      undefined,
    clicked:      undefined,
    selected:     undefined,
    limit:        0,
    limit_reached:undefined,
  }
  jQuery.extend(default_options, opts)

