Saturday, April 25, 2020

After Image path pass variable value wordpress

http://localhost/extend05/wp-content/uploads/2019/06/linksys-basic.jpg?pramod=1587816842


function add_jpeg_params($content){

preg_match_all("/https?:\/\/[^\/\s]+\/\S+\.(jpg|jpeg)/", $content, $output_array);

$items_to_replace = array_unique($output_array[0]);
$items_to_replace = array_values($items_to_replace);

for ($j = 0; $j < sizeof($items_to_replace); $j++) {

    $content = str_replace($items_to_replace[$j], $items_to_replace[$j] . '?pramod=' . time(), $content);
}

return $content;
}
add_filter('the_content','add_jpeg_params',10);
add_filter('post_thumbnail_html', 'add_jpeg_params' );

No comments:

Post a Comment