Why do images not always appear correctly on the front end?

Images are cropped to 240×180, if you are using sizes/ratios other than these you may run into problems.

 

  • You can choose a different version by going to Directories –> [Your Directory] –> Content Types –> Category –> Manage Displays –> (Name of Display to Edit). Edit the Photos display element there and select a different image size.
  • In my (Dave) opinion this is less than ideal and making full use of WP’s responsive images functionality integrated into core in 4.4 should make it possible to avoid this issue entirely.
  • There are also some restrictions on the responsiveness of images caused by Directories Pro’s use of the CSS property background-image for displaying some listing images instead of the HTML img tag. I (Dave) think using img is a better route than background-image for this usage case. See StackOverflow for further discussion of this topic.

 

Is it possible to change the image dimensions for thumbnails?

 

The plugin currently uses 240×180:

add_image_size('drts_thumbnail', 240, 180, true);

This can be overridden by adding code to the functions.php file of your theme:

add_action('init', function() {
    add_image_size('drts_thumbnail', 240, 160);
});

 

How can I enable featured images for listings?

 

  • Add to the theme’s functions.php file:
    add_post_type_support(‘directory_dir_ltg’, ‘thumbnail’);
  • Make sure to change directory_dir_ltg to the post type name of the listing in your directory. You can view this from Directories –> [Your Directory] –> Content Types.
  • If you have multiple directories, simple add multiple add_post_type_support, one for each directory.