Skip to content

Instantly share code, notes, and snippets.

@janfabry
janfabry / on-demand-resize.php
Created November 13, 2010 16:03
WordPress On-Demand image resizer plugin (first public attempt)
<?php
/*
Plugin Name: On-Demand image resizer
Plugin URI: http://www.monkeyman.be
Description: Create and store images in different sizes on demand
Version: 1.0
Author: Jan Fabry
This plugins monitors 404 requests to the uploads directory and created new images of a requested size. They are saved as new files in the upload directory, not cached somewhere, so future requests are served directly by the server. This allows you to eliminate the creation of intermediate image sizes [see monkeyman-virtual-intermediate-images] or resize images based on the size used in the editor [see monkeyman-resize-image-tags].
@janfabry
janfabry / resize-img-tags.php
Created November 13, 2010 16:04
WordPress Resize img tags plugin (first public attempt)
<?php
/*
Plugin Name: Resize img tags
Plugin URI: http://www.monkeyman.be
Description: Change image src's based on width and height specified in tag
Version: 0.1
Author: Jan Fabry
This plugin rewrites <img> tags so that the src contains width and height information. It is supposed to be used together with a plugin that can generate these resized images on the fly, like monkeyman-on-demand-resizer.
@janfabry
janfabry / virtual-intermediate-images.php
Created November 13, 2010 16:05
WordPress Virtual intermediate images plugin (first public attempt)
<?php
/*
Plugin Name: Virtual intermediate images
Plugin URI: http://www.monkeyman.be
Description: Prevent creation of actual intermediate image sizes
Version: 0.1
Author: Jan Fabry
This plugin prevents the creation of actual intermediate image sizes. It does, however, fill in all metadata attributes as if the intermediate sizes exist. It is designed to work together with a plugin that can create these images on the fly, like monkeyman-on-demand-resizer.
@janfabry
janfabry / fixed-image-cropper.js
Created December 2, 2010 15:19
WordPress Fixed Image Cropper
// pxi: pixels in image scale
// pxc: pixels in crop scale
// Helper function to create an element with optional attributes
// Doesn't jQuery already have this?
Monkeyman_FixedImageCroppper_createElement = function(tagName, attr)
{
if (!attr) {
attr = {};
}
@janfabry
janfabry / vote-groups.php
Created March 30, 2011 06:36
See which triplets of candidates were most frequent in the WPSE moderator election
<?php
$ballots = array(
array(1, 2, 3),
array(2, 4, 1),
array(5, 1, 4),
array(4, 2, 5),
array(1, 2, 4),
array(5, 4, 2),
array(6, 4, 5),
array(4, 1, 5),
@janfabry
janfabry / wpse17728.php
Created May 19, 2011 20:31
Dump WP image resize information
<?php
/*
Plugin Name: WPSE 17728
Plugin URI: http://wordpress.stackexchange.com/questions/17728/large-image-size-is-cropped-not-proportional
Description: Large image size is cropped, not proportional?
Author: jimilesku
*/
add_filter( 'intermediate_image_sizes_advanced', 'wpse17728_intermediate_image_sizes_advanced' );
function wpse17728_intermediate_image_sizes_advanced( $sizes )