joelstrategycube
Forum Replies Created
-
I responded to the latest thread regarding this issue, but posting here as well.
Created a sanitize filter specifically for this plugin that removes invalid attachments:
add_filter('sanitize_post_meta__wppcp_post_attachments', 'sanitize_wp_private_content', 10, 3); function sanitize_wp_private_content($meta_value, $meta_key, $meta_type) { // avoid infinite recursion remove_filter( current_filter(), __FUNCTION__ ); // clean meta value array $new_meta = array(); foreach( $meta_value as $key => $attachment ) { if( $attachment['attach_id'] && $attachment['attach_id'] > 0 ) { $new_meta[$key] = $attachment; } } return $new_meta; }
Forum: Plugins
In reply to: [WP Private Content Plus] Always show file attachments in my postFor anyone looking for a solution, I’ve written this code to make sure empty attachments aren’t added to the database.
add_filter('sanitize_post_meta__wppcp_post_attachments', 'sanitize_wp_private_content', 10, 3); function sanitize_wp_private_content($meta_value, $meta_key, $meta_type) { // avoid infinite recursion remove_filter( current_filter(), __FUNCTION__ ); // clean meta value array $new_meta = array(); foreach( $meta_value as $key => $attachment ) { if( $attachment['attach_id'] && $attachment['attach_id'] > 0 ) { $new_meta[$key] = $attachment; } } return $new_meta; }
Forum: Plugins
In reply to: [Crop-Thumbnails] Retina Integration@volkmar-kantor
Thank you! I was able to get something working.It’s not fully tested but if anyone stumbles across this:
/** * * Action for Crop Thumbnails plugin * Uses input crop data to generate retina size * */ function add_retina_for_cropped_thumbnails( $input, $croppedSize, $temporaryCopyFile, $currentFilePath ) { $temporaryCopyFile = generate_retina_filename( $temporaryCopyFile, '@2x' ); $retina_file = generate_retina_filename( $currentFilePath, '@2x' ); $currentFilePathInfo = pathinfo($retina_file); $currentFilePathInfo['basename'] = wp_basename($retina_file);//uses the i18n version of the file-basename $retina_w = $croppedSize['width'] * 2; $retina_h = $croppedSize['height'] * 2; $cropped = wp_crop_image( // * @return string|WP_Error|false New filepath on success, WP_Error or false on failure. $input->sourceImageId, // * @param string|int $src The source file or Attachment ID. $input->selection->x, // * @param int $src_x The start x position to crop from. $input->selection->y, // * @param int $src_y The start y position to crop from. $input->selection->x2 - $input->selection->x, // * @param int $src_w The width to crop. $input->selection->y2 - $input->selection->y, // * @param int $src_h The height to crop. $retina_w, // * @param int $dst_w The destination width. $retina_h, // * @param int $dst_h The destination height. false, // * @param int $src_abs Optional. If the source crop points are absolute. $temporaryCopyFile // * @param string $dst_file Optional. The destination file to write to. ); // delete old file $should_delete = apply_filters('crop_thumbnails_should_delete_old_file', false, // default value $input->activeImageSizes->name, $input->activeImageSizes, $cropped ); $_error = false; if( !empty($cropped) ) { if( $should_delete ) { @unlink($currentFilePathInfo['dirname'].DIRECTORY_SEPARATOR.$currentFilePathInfo['basename']); } if(!@copy($cropped, $retina_file)) { $_error = true; } if(!@unlink($cropped)) { $_error = true; } } } add_action( 'crop_thumbnails_before_crop', 'add_retina_for_cropped_thumbnails', 10, 4 ); function generate_retina_filename( $file, $suffix ) { $dir = pathinfo( $file, PATHINFO_DIRNAME ); $ext = pathinfo( $file, PATHINFO_EXTENSION ); $name = wp_basename( $file, ".$ext" ); $new_ext = strtolower( $extension ? $extension : $ext ); if ( ! is_null( $dest_path ) ) { $_dest_path = realpath( $dest_path ); if ( $_dest_path ) { $dir = $_dest_path; } } return trailingslashit( $dir ) . "{$name}{$suffix}.{$new_ext}"; }
- This reply was modified 3 years, 10 months ago by joelstrategycube.
Forum: Plugins
In reply to: [Crop-Thumbnails] Retina IntegrationJust following up on this. Thanks.
Forum: Plugins
In reply to: [Crop-Thumbnails] Retina IntegrationThanks for the quick reply. I’m not quite sure how an additional action allows me to retina-ize the current thumbnail but I appreciate any time you are able to spend on this. Let me know if there is anything you need from me.
Forum: Plugins
In reply to: [Crop-Thumbnails] Image Size LimitationsI added the plugin ‘resize on upload’ and all seems good now. I still would like to know the root cause of the error though.
Forum: Plugins
In reply to: [Crop-Thumbnails] Image Size LimitationsI advised uploading images less than 5500px wide but I will give that plugin a try as a fallback.
Here is the JS Debug output:
cropImage:{ "url": "example.com/wp-content/uploads/2019/02/menu-board-case-study-1024x683.jpg", "width": 1024, "height": 683, "gcd": "1", "ratio": 1.499267935578331, "printRatio": "1024:683", "image_size": "large" } cropData:{ "options": { "hide_size": { "post": { "thumbnail": "1" }, "page": { "thumbnail": "1" } }, "debug_js": 1, "debug_data": 1 }, "sourceImageId": 8015, "sourceImage": { "full": { "url": "example.com/wp-content/uploads/2019/02/menu-board-case-study.jpg", "width": 7151, "height": 4773, "gcd": "1", "ratio": 1.4982191493819401, "printRatio": "7151:4773", "image_size": "full" }, "large": { "url": "example.com/wp-content/uploads/2019/02/menu-board-case-study-1024x683.jpg", "width": 1024, "height": 683, "gcd": "1", "ratio": 1.499267935578331, "printRatio": "1024:683", "image_size": "large" }, "medium_large": { "url": "example.com/wp-content/uploads/2019/02/menu-board-case-study.jpg", "width": 768, "height": 513, "gcd": "3", "ratio": 1.4970760233918128, "printRatio": "256:171", "image_size": "medium_large" } }, "sourceImageMeta": { "aperture": "0", "credit": "", "camera": "", "caption": "", "created_timestamp": "1466781129", "copyright": "JENN INKOL", "focal_length": "0", "iso": "0", "shutter_speed": "0", "title": "", "orientation": "1", "keywords": [] }, "postTypeFilter": null, "imageSizes": [ { "name": "thumbnail", "nameLabel": "thumbnail", "url": "example.com/wp-content/uploads/2019/02/menu-board-case-study-150x150.jpg", "width": 150, "height": 150, "gcd": "150", "ratio": 1, "printRatio": "1:1", "hideByPostType": false, "crop": true, "active": false, "lowResWarning": false, "cacheBreak": 1571778730321 }, { "name": "blog-wide", "nameLabel": "blog-wide", "url": "example.com/wp-content/uploads/2019/02/menu-board-case-study.jpg", "width": 2650, "height": 900, "gcd": "50", "ratio": 2.9444444444444446, "printRatio": "53:18", "hideByPostType": false, "crop": true, "active": true, "lowResWarning": false, "cacheBreak": 1571778730321 }, { "name": "blog-wide-small", "nameLabel": "blog-wide-small", "url": "example.com/wp-content/uploads/2019/02/menu-board-case-study.jpg", "width": 1440, "height": 490, "gcd": "10", "ratio": 2.938775510204082, "printRatio": "144:49", "hideByPostType": false, "crop": true, "active": false, "lowResWarning": false, "cacheBreak": 1571778730321 }, { "name": "blog-index-small", "nameLabel": "blog-index-small", "url": "example.com/wp-content/uploads/2019/02/menu-board-case-study-562x319.jpg", "width": 562, "height": 319, "gcd": "1", "ratio": 1.761755485893417, "printRatio": "562:319", "hideByPostType": false, "crop": true, "active": false, "lowResWarning": false, "cacheBreak": 1571778730321 }, { "name": "blog-index-large", "nameLabel": "blog-index-large", "url": "example.com/wp-content/uploads/2019/02/menu-board-case-study-814x462.jpg", "width": 814, "height": 462, "gcd": "22", "ratio": 1.7619047619047619, "printRatio": "37:21", "hideByPostType": false, "crop": true, "active": false, "lowResWarning": false, "cacheBreak": 1571778730321 } ], "lang": { "warningOriginalToSmall": "Warning: the original image is too small to be cropped in good quality with this thumbnail size.", "cropDisabled": "Cropping is disabled for this post-type.", "waiting": "Please wait until the images are cropped.", "rawImage": "Raw", "pixel": "pixel", "instructions_header": "Quick Instructions", "instructions_step_1": "Step 1: Choose an image-size from the list.", "instructions_step_2": "Step 2: Change the selection of the image above.", "instructions_step_3": "Step 3: Click on \"Save Crop\".", "label_crop": "Save Crop", "label_same_ratio": "Crop all images with same ratio at once", "label_deselect_all": "deselect all", "dimensions": "Dimensions:", "ratio": "Ratio:", "cropped": "cropped", "lowResWarning": "Original image size too small for good crop quality!", "notYetCropped": "Not yet cropped by wordpress.", "message_image_orientation": "This image has an image orientation value in its exif-metadata. Be aware that this may result in rotatated or mirrored images on safari ipad / iphone.", "script_connection_error": "The plugin can not correctly connect to the server.", "noPermission": "You are not permitted to crop the thumbnails." }, "hiddenOnPostType": false }
Forum: Plugins
In reply to: [Crop-Thumbnails] Image Size Limitations7952×5304Correction:
The dimensions are 7151 by 4773 pixels
- This reply was modified 5 years, 1 month ago by joelstrategycube.
Forum: Plugins
In reply to: [Crop-Thumbnails] Image Size LimitationsThanks for the insight. Unfortunately, I need a specific aspect ratio for these custom image sizes so I don’t think that will work for me here.
Forum: Plugins
In reply to: [Crop-Thumbnails] Image Size LimitationsHey Volkmar,
I am experiencing the same issue with cropping one custom set image size (set via functions.php). I’ve found it has been related to images over ~6000px wide. From the screenshot, you can see the other custom image sizes were successfully cropped.
https://www.dropbox.com/s/4dvgwdq640rllqx/crop_thumbnails.png?dl=0
Here’s my debug output:
[ "validated input data", { "selection": { "x": 0, "y": 1658, "x2": 7151, "y2": 4087, "w": 7151, "h": 2428.8708939065878 }, "sourceImageId": 8015, "activeImageSizes": [ { "name": "blog-wide", "width": 2650, "height": 900, "ratio": 2.9444444444444446, "crop": 1 } ] }, "Image filename has changed (blog-wide)", "filename: /nas/content/live/explorerstage/wp-content/uploads/2019/02/menu-board-case-study-2650x900.jpg", "error on menu-board-case-study-2650x900.jpg", { "blog-wide": [ "Can't copy temporary file to media library.", "Can't delete temporary file." ] } ]
Here is the plugin test output:
info Crop-Thumbnails 1.2.5 info PHP 7.2.23-1+ubuntu18.04.1+deb.sury.org+1 info PHP memory limit 512M info WP_Image_Editor_Imagick (choosed WordPress imageeditor class for jpg) success Temporary directory exists success Copy testfile to temporary directory success Testfile was successfully added to media-library. (ID:8017) success Cropping the file success Cropped image dimensions are correct. success Test-attachement successfull deleted (ID:8017) success Remove testfile from temporary directory info Tests complete
Here’s what I’ve tried:
– ran image through compressor as well as re-saved the image (removing all original meta data). Both of these tests resulted in same error.
– resized the image to 5500px and cropping workedPlease let me know what I can try to further debug this issue. Thanks in advance.