Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This will only work for Site Reviews v5
- /**
- * Add a new WordPress image size for Site Reviews avatars
- * Paste this in your active theme's functions.php file.
- * This will only work for Site Reviews v5
- * @return void
- */
- add_action('after_setup_theme', function () {
- $fallback = 40; // fallback width/height in pixels
- $size = apply_filters('glsr_get_option', $fallback, 'reviews.avatars_size', $fallback);
- add_image_size('site-reviews-avatar', $size, $size, true);
- });
- /**
- * Replaces the review avatar with the featured image thumbnail of the assigned page
- * Paste this in your active theme's functions.php file.
- * @param string $value
- * @param \GeminiLabs\SiteReviews\Modules\Html\Tags\ReviewAvatarTag $tag
- * @return string
- */
- add_filter('site-reviews/review/value/avatar', function ($value, $tag) {
- $firstAssignedPostId = array_shift($tag->review->assigned_posts);
- if (empty($firstAssignedPostId)) {
- return $value;
- }
- $thumbnail = get_the_post_thumbnail($firstAssignedPostId, 'site-reviews-avatar');
- if (empty($thumbnail)) {
- return $value;
- }
- return $thumbnail;
- }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement