Categories
Imagick PHP WordPress

Imagick – Generate Preview Image of PDF

<?php

$file          = get_attached_file( $attachment_id );
$output_format = "jpeg";
$antialiasing  = "4";
$preview_page  = "1";
$resolution    = "300";
$output_file   = 'srv/www/chetan/doc/' . $attachment_id . '_imagick_preview.jpg';
$exec_command  = "gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=" . $output_format . " ";
$exec_command  .= "-dTextAlphaBits=" . $antialiasing . " -dGraphicsAlphaBits=" . $antialiasing . " ";
$exec_command  .= "-dFirstPage=" . $preview_page . " -dLastPage=" . $preview_page . " ";
$exec_command  .= "-r" . $resolution . " ";
$exec_command  .= "-sOutputFile=" . $output_file . " '" . $file . "'";

exec( $exec_command, $command_output, $return_val );
Categories
Search WordPress

WordPress Exclude pages from search

function chet_tips_modify_search_filter($query) {

  if ($query->is_search) {

    $query->set('post_type', 'post');

  }

  return $query;

}

add_filter('pre_get_posts','chet_tips_modify_search_filter');
Categories
Search WordPress

WordPress Exclude categories from search

function chet_tips_search_filter($query) {

  if ( $query->is_search && ! is_admin() ) {

    $query->set('cat','8,15'); 

  }

  return $query; 

}

add_filter('pre_get_posts','chet_tips_search_filter');