Last active
August 15, 2019 08:26
-
-
Save zecka/93d11cd384b6d7d6ca1f846e7c06c9da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// attach a post type to pictifly regeneration | |
add_filter('pf_post_type_regenerate', 'prefix_pf_post_type_regenerate', 1, 1); | |
function prefix_pf_post_type_regenerate($post_types){ | |
$post_types=['custom_type']; | |
return $post_types; | |
} | |
// Create custom method to regenerate image | |
add_action('pf_post_images_regenerate', 'prefix_pf_post_images_regenerate',10, 2); | |
function prefix_pf_post_images_regenerate($post_id, $post_type){ | |
global $_pf_regenerated_imgs; | |
if($post_type=="custom_type"){ | |
$thumb_id = get_post_thumbnail_id($post_id); | |
if($thumb_id){ | |
$_pf_regenerated_imgs[] = pf_get_simple($thumb_id, 200, 200, true); | |
} | |
$images = get_field('images', $post_id); | |
if($images){ | |
foreach($images as $image){ | |
$_pf_regenerated_imgs[] = pf_img($image, "custom_size", false); | |
$_pf_regenerated_imgs[] = pf_get_simple($image, 200, 200, true); | |
$_pf_regenerated_imgs[] = pf_get_simple($image, 400, 400, true); | |
$_pf_regenerated_imgs[] = pf_get_simple($image, 600, 600, true); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment