matthewruddy / wordpress-timthumb-alternative Goto Github PK
View Code? Open in Web Editor NEWAn image resizing function that provides Wordpress users with an alternative to Timthumb.php
An image resizing function that provides Wordpress users with an alternative to Timthumb.php
Now that 3.5 has better support for controlling the image crop, it would be really awesome to integrate that into this script. I'm going to take a stab at it myself. I'll update this with code if I'm able to work it out.
More info on the crop capabilities: http://www.slideshare.net/markoheijnen/image-manipulation-in-wordpress-35
Don't know why its not working on multisite its working fine in local host when i upload theme on multisite its stop working and show showing original image size.
Hi!
I know php and developing Wordpress themes fairly well ( but still consider myself a n00b) and am having trouble creating a function to use with this alternative for featured images. I am trying to pass the wp_get_attachment_image_src( ) call using this :
function tpp_custom_img( $thumb_size, $image_width, $image_height ) {
global $post;
$params = array( 'width' => $image_width, 'height' => $image_height );
$url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID, '' ), $thumb_size );
$custom_img_src = matthewruddy_image_resize( $url[0], $params );
return $custom_img_src;
}
But it is not working. please help.
Using a script like retinajs assumes that the filename of the retina image should have a suffix @2x
as described in Apple's documentation, and not simply double the resolution in the filename.
So if we have an image called image.png
and we upload it creating a thumbnail with dimentions 300x120, the resulting image files should be like this:
image-300x120.png
(normal version)
[email protected]
(retina version)
Instead, they are like this:
image-300x120.png
(normal version)
image-600x240.png
(retina version)
HOW do you use images named like this for retina screens?
This seems to be expected behavior of the script because WordPress treats this situation as if the images are external.
My situation occurred because the initial WordPress install took place under a non-www domain. After migrating the site, it was changed to the www version which caused the script to fail. In the browser, the images still appeared with the www prepended, but in the database they were not.
I don't think this requires a patch, although I think it could use an extra error handling statement somewhere. At the very least you might want to mention the issue in the documentation.
To allow resize based on one dimension (like WordPress currently works)
Timbthumb have option to choose where will be crop. Do you have any solution for that
Hey, this looks like a promising script. Just wondering what happens when the main image is deleted from the media library - are the thumbnails removed as well? I've found with VTResize that old thumbnails stick around and sometimes become associated with new images with the same filename.
$url = $job->getLogoUrl() ; // Required
$width = 100; // Optional. Defaults to '150'
$height = 50; // Optional. Defaults to '150'
$crop = true; // Optional. Defaults to 'true'
$retina = false; // Optional. Defaults to 'false'
// Call the resizing function (returns an array)
$image = matthewruddy_image_resize( $url, $width, $height, $crop, $retina );
if ( is_wp_error( $image ) ) {
echo $image->get_error_message() ; // Displays error message returned from resizing function
} else {
$img = $image['url'];
echo "<img src='$img' alt='Logo' />";
}
If I pass an image through this script with crop set to false, instead of simply resizing the image, it nastily stretches/squashes the image into the specified width/height.
Example: original image is 100x500.
I want the script to take the values width:50, height:50, crop:false and return me an image that's 10x50. What is actually does is returns that portrait image squashed into a 50x50 space.
Hi, thanks for the great script.
Maybe I'm wrong but near the top of matthewruddy_image_resize() for WP 3.5+ you've got:
$width = ( $width ) ? get_option( 'thumbnail_size_w' ) : $width;
$height = ( $height ) ? get_option( 'thumbnail_size_h' ) : $height;
Isn't this backwards? Shouldn't it use get_option when $width/$height are NOT set? Something like:
$width = ( !isset($width) ) ? get_option( 'thumbnail_size_w' ) : $width;
$height = ( !isset($height) ) ? get_option( 'thumbnail_size_h' ) : $height;
Also I've got to declare global $wp_version; to get into this function.
Love the script - was working perfect on my localhost, then I uploaded to my server and was given a fatal error because of these four lines.
$width = $width ?: get_option( 'thumbnail_size_w' );
$height = $height ?: get_option( 'thumbnail_size_h' );
Seems the server didn't like the ?: syntax.
I commented these lines out for now and the script still works.
Any idea why this would happen?
Thanks!
Sorry to ask such a n00b question but I need help installing/using this script. I am using the Good Idea wordpress theme (http://themes.goodlayers.com/goodidea/) and the thumbnails on the home page are not loading the retina versions because timthumb is resizing them. I would really like to just disable timthumb altogether but am having a hard time making that happen so in further searching I stumbled upon this script and it sounds like this can do what I need it to do... correct? If so, can you provide a little more clear instructions on how to install/implement in my current situation?
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.