Press. * @param string $overlay_image The ID of the post. * @param string $position Image position. */ private function create_overlay_image( $image_file, $overlay_image, $position ) { wp_raise_memory_limit( 'image' ); /** * Filter: 'rank_math/social/create_overlay_image' - Change the create_overlay_image arguments. */ $args = $this->do_filter( 'social/create_overlay_image', compact( 'image_file', 'overlay_image', 'position' ) ); extract( $args ); // phpcs:ignore if ( empty( $image_file ) || empty( $overlay_image ) ) { return; } $method = 'generate_image_' . $this->image_module; $this->$method( $image_file, $overlay_image, $position ); die(); } /** * Generate image using the GD module. * * @param string $image_file The permalink generated for this post by WordPress. * @param string $overlay_image The ID of the post. * @param string $position Image position. */ private function generate_image_gd( $image_file, $overlay_image, $position ) { $imagecreatefrom = $this->get_imagecreatefrom_method( $image_file ); $overlay_imagecreatefrom = $this->get_imagecreatefrom_method( $overlay_image ); if ( ! $imagecreatefrom || ! $overlay_imagecreatefrom ) { return; } $stamp = $overlay_imagecreatefrom( $overlay_image ); $image = $imagecreatefrom( $image_file ); if ( ! $image || ! $stamp ) { return; } $stamp_width = imagesx( $stamp ); $stamp_height = imagesy( $stamp ); $img_width = imagesx( $image ); if ( $stamp_width > $img_width ) { $stamp = imagescale( $stamp, $img_width ); } $margins = $this->get_position_margins_gd( $position, $image, $stamp ); // Copy the stamp image onto our photo using the margin offsets and the photo width to calculate positioning of the stamp. imagecopy( $image, $stamp, $margins['left'], $margins['top'], 0, 0, $stamp_width, $stamp_height ); // Output and free memory. header( 'Content-type: image/png' ); imagepng( $image ); imagedestroy( $image ); } /** * Generate image using the Imagick module. * * @param string $image_file The permalink generated for this post by WordPress. * @param string $overlay_image The ID of the post. * @param string $position Image position. * * @return void */ private function generate_image_imagick( $image_file, $overlay_image, $position ) { try { $stamp = new \Imagick( $overlay_image ); $image = new \Imagick( $image_file ); if ( ! $image->valid() || ! $stamp->valid() || ! $image->getImageFormat() || ! $stamp->getImageFormat() ) { return; } // Select the first frame to handle animated images properly. if ( is_callable( [ $stamp, 'setIteratorIndex' ] ) ) { $stamp->setIteratorIndex( 0 ); } if ( is_callable( [ $image, 'setIteratorIndex' ] ) ) { $image->setIteratorIndex( 0 ); } } catch ( \Exception $e ) { return; } $stamp_width = $stamp->getImageWidth(); $img_width = $image->getImageWidth(); if ( $stamp_width > $img_width ) { $stamp->resizeImage( $img_width, 0, \Imagick::FILTER_LANCZOS, 1 ); } $margins = $this->get_position_margins_imagick( $position, $image, $stamp ); // Copy the stamp image onto our photo using the margin offsets and the photo width to calculate positioning of the stamp. $image->compositeImage( $stamp, \Imagick::COMPOSITE_OVER, $margins['left'], $margins['top'] ); // Output. header( 'Content-type: image/png' ); echo $image->getImageBlob(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped // Free memory. $image->clear(); $image->destroy(); $stamp->clear(); $stamp->destroy(); } /** * Check if secret key is valid. * * @param int $id The ID of the attachment. * @param string $type Overlay type. * @param string $secret Secret key. * * @return boolean */ private function is_secret_valid( $id, $type, $secret ) { return md5( $id . $type . wp_salt( 'nonce' ) ) === $secret; } }
Fatal error: Uncaught Error: Class 'RankMath\Thumbnail_Overlay' not found in /home/candoodesigncom/public_html/wp-content/plugins/seo-by-rank-math/includes/class-common.php:51 Stack trace: #0 /home/candoodesigncom/public_html/wp-content/plugins/seo-by-rank-math/rank-math.php(297): RankMath\Common->__construct() #1 /home/candoodesigncom/public_html/wp-content/plugins/seo-by-rank-math/rank-math.php(185): RankMath->instantiate() #2 /home/candoodesigncom/public_html/wp-content/plugins/seo-by-rank-math/rank-math.php(164): RankMath->setup() #3 /home/candoodesigncom/public_html/wp-content/plugins/seo-by-rank-math/rank-math.php(554): RankMath::get() #4 /home/candoodesigncom/public_html/wp-content/plugins/seo-by-rank-math/rank-math.php(558): rank_math() #5 /home/candoodesigncom/public_html/wp-settings.php(522): include_once('/home/candoodes...') #6 /home/candoodesigncom/public_html/wp-config.php(100): require_once('/home/candoodes...') #7 /home/candoodesigncom/public_html/wp-load.php(50): require_once('/home/candoodes...') #8 /hom in /home/candoodesigncom/public_html/wp-content/plugins/seo-by-rank-math/includes/class-common.php on line 51