|
bash
Create Resized and Renamed Non-Retina Images with Sed & ImageMagick »
|
ls | sed -n 's/\(.*\)\(@2x\)\(.*\)/convert "\1\2\3" -resize 50% "\1\3"/p' | sh |
|
WordPress
Add IPTC Keywords and Category Metadata to Uploaded Images in WordPress »
|
function fifteenccgal_add_additional_image_meta( $meta, $file, $sourceImageType )
{
$image_file_types = apply_filters(
'wp_read_image_metadata_types',
array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM )
);
// Check that it's an image type
if ( in_array( $sourceImageType, $image_file_types )
&& function_exists('iptcparse') ) {
getimagesize($file, $info);
$iptc = iptcparse($info['APP13']);
$meta['category'] = $iptc['2#015'];
$meta['keywords'] = $iptc['2#025'];
}
return $meta;
}
add_filter('wp_read_image_metadata', 'fifteenccgal_add_additional_image_meta', 10, 3); |
|
WordPress
Add custom image thumbnail sizes to the media library’s insert size choices »
|
/**
* Add intermediate image sizes to media gallery modal dialog
*/
function nf_add_image_sizes_to_editor( $form_fields, $post ) {
if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) )
return $form_fields;
if ( is_array($imagedata['sizes']) ) {
foreach ( $imagedata['sizes'] as $size => $val ) {
if ( $size == 'teaser-image' ) {// put your thumbnail image name(s) here
$css_id = "image-size-{$size}-{$post->ID}";
$pretty_size = ucwords(str_replace('-', ' ' , $size));
$html .= '';
$html .= ''.$pretty_size.'';
$html .= ' '.sprintf( __("(%d × %d)"), $val['width'], $val['height'] ). '';
$html .= '';
}
}
}
$form_fields['image-size']['html'] .= $html;
return $form_fields;
}
add_filter( 'attachment_fields_to_edit', 'nf_add_image_sizes_to_editor', 100, 2 );
|
|
jQuery
Prevent right-click context menu on images with jQuery »
|
jQuery(function ($){
$('img').live('contextmenu', function(e){
alert('These images are copyright [COMPANY] and may only be used with explicit permission.');
return false;
});
});
|
|
iOS
Add a pulsating image to a new CALayer centred on an existing view. »
|
// Somewhere in the setup code, possible awakeFromNib if relevant. NOT in drawRect:!
UIImage *img = [UIImage imageNamed:@"BigHand"];
UIGraphicsBeginImageContext(img.size);
[img drawAtPoint:CGPointMake(0, 0)]; // handy!
CALayer *newLayer = [CALayer layer];
newLayer.bounds = CGRectMake(0, 0, img.size.width, img.size.height);
newLayer.position = CGPointMake(self.layer.bounds.size.width/2.0, self.layer.bounds.size.height/2.0); // centred
newLayer.contentsScale = self.layer.contentsScale; // for retina compat. Make sure you've set you view's main layer
newLayer.contents = (__bridge id)UIGraphicsGetImageFromCurrentImageContext().CGImage;
newLayer.opacity = 1.0;
UIGraphicsEndImageContext();
// Create the animation...
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"opacity"];
anim.fromValue = [NSNumber numberWithFloat:0.6];
anim.toValue = [NSNumber numberWithFloat:1.0];
anim.duration = 0.7;
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
anim.autoreverses = YES;
anim.repeatCount = HUGE_VALF; // repeat forever
[newLayer addAnimation:anim forKey:@"opacity"];
[self.layer addSublayer:newLayer]; |