ripperdoc
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Fixing WordPress
In reply to: Cropping images and thumbnails in Media Library editorHi, I did a hack that solves the most urgent issue. The problem is that images changed by media library editor gets new filenames – any old references to the thumbnail will therefore point to the unedited version. This hack will rename the edited image to the original (overwriting it!). Only affects intermediate size, e.g. 150×150 thumbnails, at the moment.
/** * Edited images using media library image editor gets new filenames, so * will not automatically be used by posts where they have already been inserted. * This filter detects those re-crops and changes the name back to the original * Caution: Will overwrite original thumbnail. Only affects "intermediate size". * By ripperdoc.net */ function overwrite_recropped_thumbnail($resized_file) { // Remove timestamp added to re-cropped images. TODO improve regex to avoid // accidental path changes $new_path = preg_replace( '/-e([0-9]+)-/', '-', $resized_file, -1, $count ); if($count>0) { // The file path had the timestamp, move back to original name rename($resized_file, $new_path); return $new_path; } else { // do nothing return $resized_file; } } add_filter('image_make_intermediate_size', 'overwrite_recropped_thumbnail',10);Forum: Plugins
In reply to: Permalinks not working in plugin codeActually, found the issue: the plugin creates draft posts, and they are not given permalinks (although in the post editor, they are appearing with a permalink). Worth noting for others that if your plugin works with draft posts, permalink functions does not work.
I circumvented it with a filter that temporarily pretends a post is not in draft in order for it to get a permalink.
Viewing 2 replies - 1 through 2 (of 2 total)