Title: Modifications
Last modified: December 9, 2017

---

# Modifications

 *  Plugin Author [Pektsekye](https://wordpress.org/support/users/pektsekye/)
 * (@pektsekye)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/modifications-8/)
 * List of available modifications:
    - [Vehicle image from directory](https://wordpress.org/support/topic/modifications-8/#post-9766528)
 * **Please do not reply to this Topic!**
    If you have a question or a suggestion
   start a new topic.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Pektsekye](https://wordpress.org/support/users/pektsekye/)
 * (@pektsekye)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/modifications-8/#post-9766528)
 * **Vehicle image from directory**
 * It will display image for selected vehicle on the search results page.
    [Screenshot](http://hottons.com/demo/wp/ymm/screenshots/modifications/vehicle_image.png)
 * /wp-content/plugins/ymm-search/view/frontend/templates/horizontal_selector.phtml
   
   modified lines 73-105
 *     ```
       <?php
   
         $vehicleImageUrl = '';
   
         if ($this->isResultsPage()){
   
          $imagesDir = 'car_images';
   
          $dir = ABSPATH . '/'. $imagesDir;
          if (file_exists($dir)){
           $vehicleImages = array();
           $selectedVehicle = preg_replace('/[^a-z\d]/', '', strtolower(implode('', (array) $this->getSelectedParameters())));
           $imageFiles = array_diff(scandir($dir), array('..', '.'));
           foreach($imageFiles as $file){
             $vehicle = preg_replace('/[^a-z\d]/', '', strtolower(pathinfo($file, PATHINFO_FILENAME))); // converts Acura_CL_Type-S_2003.jpg to acuracltypes2003
             if (strpos($selectedVehicle, $vehicle) === 0) { // selected vehicle starts with image file name
               $length = strlen($vehicle);
               $vehicleImages[$length] = $file;
             }    
           }
           if (count($vehicleImages) > 0){
             krsort($vehicleImages);
             $fileName = array_shift($vehicleImages); // we use the longest image name ex.: bmw_x5.jpg instead of bmw.jpg
             $vehicleImageUrl = site_url('/'.$imagesDir.'/') . $fileName; 
           }
          }
         } 
       ?>
       <?php if ($vehicleImageUrl != ''): ?>
         <div>
           <img src="<?php echo esc_url($vehicleImageUrl); ?>"/>
         </div>
       <?php endif; ?> 
       ```
   
 * Create a directory:
    /car_images
 * Upload files to it:
    /car_images/bmw.jpg /car_images/Daihatsu_Altis_2008.jpeg
 * It will remove everything except letters and digits and will make it lover case
   before searching the image file.
    Example: **Acura_CL_Type-S_2003.jpg** will 
   converted to **acuracltypes2003**
 * [Download the modified files](http://hottons.com/demo/wp/ymm/screenshots/modifications/vehicle_image_from_directory.zip)
 * Tested on:
    WP 4.9.1 WC 3.1.2 YMM 1.0.8
 *  Plugin Author [Pektsekye](https://wordpress.org/support/users/pektsekye/)
 * (@pektsekye)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/modifications-8/#post-9772808)
 * List of available modifications is now on the plugin description page [link](https://wordpress.org/plugins/ymm-search)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Modifications’ is closed to new replies.

 * ![](https://ps.w.org/ymm-search/assets/icon-256x256.png?rev=1750193)
 * [Year Make Model Search for WooCommerce](https://wordpress.org/plugins/ymm-search/)
 * [Support Threads](https://wordpress.org/support/plugin/ymm-search/)
 * [Active Topics](https://wordpress.org/support/plugin/ymm-search/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ymm-search/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ymm-search/reviews/)

 * 2 replies
 * 1 participant
 * Last reply from: [Pektsekye](https://wordpress.org/support/users/pektsekye/)
 * Last activity: [8 years, 6 months ago](https://wordpress.org/support/topic/modifications-8/#post-9772808)
 * Status: not a support question