Add Bootstrap img-responsive class to images.
974336
def make_images_responsive(app, doctree):
    

    for fig in doctree.traverse(condition=nodes.figure):
        if 'thumbnail' in fig['classes']:
            continue

        for img in fig.traverse(condition=nodes.image):
            img['classes'].append('img-responsive')
1081987
def update(self, newinfo):
        ''''''
        self.imgstr = newinfo.imgstr
        self.width = newinfo.width
        self.height = newinfo.height
        if self.imgpanel is not None:
            self.imgpanel.set_image(self.img())
386790
@PreAuthorize("hasAnyRole('ROLE_SU')")
  @PostMapping(value = "/add-bootstrap-theme")
  public @ResponseBody Style addBootstrapTheme(
      @RequestParam(value = "bootstrap3-style") MultipartFile bootstrap3Style,
      @RequestParam(value = "bootstrap4-style", required = false) MultipartFile bootstrap4Style)
      throws MolgenisStyleException {
    String styleIdentifier = bootstrap3Style.getOriginalFilename();
    try {
      String bs4FileName = null;
      InputStream bs3InputStream = null;
      InputStream bs4InputStream = null;
      try {
        bs3InputStream = bootstrap3Style.getInputStream();
        if (bootstrap4Style != null) {
          bs4FileName = bootstrap4Style.getOriginalFilename();
          bs4InputStream = bootstrap4Style.getInputStream();
        }
        return styleService.addStyle(
            styleIdentifier,
            bootstrap3Style.getOriginalFilename(),
            bs3InputStream,
            bs4FileName,
            bs4InputStream);
      } finally {
        if (bs3InputStream != null) {
          bs3InputStream.close();
        }
        if (bs4InputStream != null) {
          bs4InputStream.close();
        }
      }
    } catch (IOException e) {
      throw new MolgenisStyleException("unable to add style: " + styleIdentifier, e);
    }
  }
84668
def change(self, inpt, hashfun=DEFAULT_HASHFUN):
        """"""
        self.img = self.__create_image(inpt, hashfun)
455869
def gen_image(img, width, height, outfile, img_type='grey'):
    """"""
    assert len(img) == width * height or len(img) == width * height * 3

    if img_type == 'grey':
        misc.imsave(outfile, img.reshape(width, height))

    elif img_type == 'color':
        misc.imsave(outfile, img.reshape(3, width, height))
3390
function (imagen, width, height, quality, type, ratio, centerCrop, resizeIf) {
    var deferred = $q.defer();
    var canvasElement = document.createElement('canvas');
    var imageElement = document.createElement('img');
    imageElement.setAttribute('style', 'visibility:hidden;position:fixed;z-index:-100000');
    document.body.appendChild(imageElement);

    imageElement.onload = function () {
      var imgWidth = imageElement.width, imgHeight = imageElement.height;
      imageElement.parentNode.removeChild(imageElement);
      if (resizeIf != null && resizeIf(imgWidth, imgHeight) === false) {
        deferred.reject('resizeIf');
        return;
      }
      try {
        if (ratio) {
          var ratioFloat = upload.ratioToFloat(ratio);
          var imgRatio = imgWidth / imgHeight;
          if (imgRatio < ratioFloat) {
            width = imgWidth;
            height = width / ratioFloat;
          } else {
            height = imgHeight;
            width = height * ratioFloat;
          }
        }
        if (!width) {
          width = imgWidth;
        }
        if (!height) {
          height = imgHeight;
        }
        var dimensions = calculateAspectRatioFit(imgWidth, imgHeight, width, height, centerCrop);
        canvasElement.width = Math.min(dimensions.width, width);
        canvasElement.height = Math.min(dimensions.height, height);
        var context = canvasElement.getContext('2d');
        context.drawImage(imageElement,
          Math.min(0, -dimensions.marginX / 2), Math.min(0, -dimensions.marginY / 2),
          dimensions.width, dimensions.height);
        deferred.resolve(canvasElement.toDataURL(type || 'image/WebP', quality || 0.934));
      } catch (e) {
        deferred.reject(e);
      }
    };
    imageElement.onerror = function () {
      imageElement.parentNode.removeChild(imageElement);
      deferred.reject();
    };
    imageElement.src = imagen;
    return deferred.promise;
  }
1045716
private void addResponsiveExample() {
		add(new WHeading(HeadingLevel.H2, "Default responsive design"));
		add(new ExplanatoryText("This example applies the theme's default responsive design rules for ColumnLayout.\n "
				+ "The columns have width and alignment and there is also a hgap and a vgap."));
				WPanel panel = new WPanel();
		panel.setLayout(new ColumnLayout(new int[]{33, 33, 33},
				new Alignment[]{Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT}, 12, 18));
		panel.setHtmlClass(HtmlClassProperties.RESPOND);
		add(panel);
		panel.add(new BoxComponent("Left"));
		panel.add(new BoxComponent("Center"));
		panel.add(new BoxComponent("Right"));
		panel.add(new BoxComponent("Left"));
		panel.add(new BoxComponent("Center"));
		panel.add(new BoxComponent("Right"));
	}
513554
public function boot()
    {
        // Enable post-thumbnail support.
        $this->enable_thumbnail_support();

        // Register all image sizes.
        $this->register_image_sizes();

        // Remove all default image sizes.
        if (Config::get('images.reset_image_sizes') !== false) {
            $this->add_filter('intermediate_image_sizes_advanced', 'remove_default_image_sizes');
            $this->add_filter('intermediate_image_sizes_advanced', 'remove_custom_image_sizes');
            $this->add_filter('intermediate_image_sizes', 'remove_default_image_sizes');
        }

        if (! empty($this->size_dropdown_names)) {
            $this->add_filter('image_size_names_choose', 'enable_custom_image_sizes');
        }
    
        // Set default image size dropdown value.
        if (! empty(Config::get('images.insert_image_default_size'))) {
            $this->add_filter('after_setup_theme', 'set_insert_image_default_size');
        }

        if (Config::get('images.dynamic_image_sizes') !== false) {
            $this->add_filter('image_downsize', 'generate_dynamic_image');
        }
    }
721408
def resize_to_fill(width, height, img, gravity='Center')
			cols, rows = img[:dimensions]
			img.combine_options do |cmd|
				if width != cols || height != rows
					scale_x = width/cols.to_f
					scale_y = height/rows.to_f
					if scale_x >= scale_y
						cols = (scale_x * (cols + 0.5)).round
						rows = (scale_x * (rows + 0.5)).round
						cmd.resize "#{cols}"
					else
						cols = (scale_y * (cols + 0.5)).round
						rows = (scale_y * (rows + 0.5)).round
						cmd.resize "x#{rows}"
					end
				end

				cmd.gravity gravity
				cmd.background 'rgba(255,255,255,0.0)'
				cmd.extent "#{width}x#{height}" if cols != width || rows != height
			end
		end
575780
public function imgAreaSelect()
    {
        $this->jquery();

        $this->Html->script('libs/img-area-select.min.js', $this->_setOptions([
            'alias'  => __FUNCTION__,
            'weight' => self::WEIGHT_LIB
        ]));

        return $this;
    }
251421
private function define_public_hooks() {

		$plugin_public = new Dynamic_Image_Resizer_Public( $this->get_plugin_name(), $this->get_version() );

		$this->loader->add_action( 'max_srcset_image_width', $plugin_public, 'disable_max_srcset_image_width' );
		$this->loader->add_action( 'image_downsize', $plugin_public, 'resize_image', 10, 3 );

	}
401202
function addClass( element, cssClass ) {
   if( element.classList ) {
      element.classList.add( cssClass );
      return;
   }
   element.className += ` ${cssClass}`;
}
572114
def make_img_widget(cls, img, layout=Layout(), format='jpg'):
        ""
        return widgets.Image(value=img, format=format, layout=layout)
906438
public function addClass(ResponsiveImageClass $class)
    {
        $this->classes_added = true;
        if (array_key_exists($class->getName(), $this->classes)) {
            throw new \Exception(sprintf('A responsive image class with name "%s" is already registered', $class->getName()));
        }
        if ($this->default_filters instanceof FilterInterface) {
            $class->addFilter($this->default_filters);
        }
        if ($this->default_post_filters instanceof FilterInterface) {
            $class->addPostFilter($this->default_post_filters);
        }
        if ($this->default_scaling_algorithm != '') {
            $class->setScaleAlgorithm($this->default_scaling_algorithm);
        }
        if ($this->default_output_type_map instanceof OutputTypeMap) {
            $class->setOutputTypeMap($this->default_output_type_map);
        }
        $this->classes[$class->getName()] = $class;
    }
248572
function preloadImage(img, onload, onerror) {
            // create new Image object and add to list
            imgList[img.name] = new Image();
            imgList[img.name].onload = onload;
            imgList[img.name].onerror = onerror;
            if (typeof (api.crossOrigin) === "string") {
                imgList[img.name].crossOrigin = api.crossOrigin;
            }
            imgList[img.name].src = img.src + api.nocache;
        }
209279
public function make_content_images_responsive( $content ) {
		// Select images in content
		if ( ! preg_match_all( '/<img [^>]+>/', $content, $matches ) ) {
			return $content;
		}

		$selected_images = array();
		$attachment_ids  = array();

		/**
		 * Loop through possible images and get attachment ids.
		 *
		 * Ignore images that already contain a srcset.
		 */
		foreach ( $matches[0] as $image ) {
			if ( false === strpos( $image, ' srcset=' )
				&& preg_match( '/wp-image-([0-9]+)/i', $image, $class_id )
				&& ( $attachment_id = absint( $class_id[1] ) )
			) {
				/**
				 * If exactly the same image tag is used more than once, overwrite it.
				 * All identical tags will be replaced later with str_replace().
				 */
				$selected_images[ $image ] = $attachment_id;

				// Overwrite the ID when the same image is included more than once.
				$attachment_ids[ $attachment_id ] = true;
			}
		}

		/**
		 * Warm object cache for use with 'get_post_meta()'.
		 *
		 * To avoid making a database call for each image, a single query warms the object cache
		 * with the meta information for all images.
		 */
		if ( count( $attachment_ids ) > 1 ) {
			update_meta_cache( 'post', array_keys( $attachment_ids ) );
		}

		// Loop through images and apply responsive markup
		foreach ( $selected_images as $image => $attachment_id ) {
			$image_updated = $this->generate_srcset_and_sizes( $image, $attachment_id );
			$content       = str_replace( $image, $image_updated, $content );
		}

		return $content;
	}
638557
function preloadImages( images, callback ) {

    function _preload( asset ) {
        asset.img = new Image();
        asset.img.src = 'img/' + asset.id+'.png';

        asset.img.addEventListener("load", function() {
            _check();
        }, false);

        asset.img.addEventListener("error", function(err) {
            _check(err, asset.id);
        }, false);
    }

    var loadc = 0;
    function _check( err, id ) {
        if ( err ) {
            alert('Failed to load ' + id );
        }
        loadc++;
        if ( images.length == loadc )
            return callback()
    }

    images.forEach(function(asset) {
        _preload( asset );
    });
}