Pictures Configuration

Configure image handling and sizes through the Combo plugin.

Pictures Configuration Options

The pictures section in your config.yml file controls image handling and sizes:

1
pictures:
2
yearmonth_folders: true # Organize uploads by year/month
3
4
placeholder: # Image placeholder settings
5
text: 'No image'
6
7
thumbnail: # Default thumbnail size
8
width: 150
9
height: 150
10
crop: true
11
12
sizes: # Custom image sizes
13
medium:
14
width: 768
15
height: 0
16
crop: false
17
large:
18
width: 1200
19
height: 0
20
crop: false
21
hero:
22
width: 1920
23
height: 600
24
crop: true
25
square:
26
width: 400
27
height: 400
28
crop: true

Upload Organization

yearmonth_folders

Controls whether uploads are organized into year/month folders. Set to true to organize uploads by year/month, or false to place all uploads in a single folder.

1
pictures:
2
yearmonth_folders: true # Organize uploads by year/month

Placeholder Settings

placeholder

Controls the text displayed in image placeholders when no image is available.

1
pictures:
2
placeholder:
3
text: 'No image available'

Default Thumbnail Size

thumbnail

Controls the default thumbnail size. This overrides the WordPress default thumbnail size.

1
pictures:
2
thumbnail:
3
width: 150
4
height: 150
5
crop: true

Parameters:

  • width: Width in pixels
  • height: Height in pixels
  • crop: Whether to crop the image to exact dimensions (true) or maintain aspect ratio (false)

Custom Image Sizes

sizes

Defines custom image sizes for your theme. These sizes are generated when images are uploaded.

1
pictures:
2
sizes:
3
medium: # Override default medium size
4
width: 768
5
height: 0
6
crop: false
7
8
large: # Override default large size
9
width: 1200
10
height: 0
11
crop: false
12
13
hero: # Custom hero image size
14
width: 1920
15
height: 600
16
crop: true
17
18
square: # Custom square image size
19
width: 400
20
height: 400
21
crop: true
22
23
portrait: # Custom portrait image size
24
width: 400
25
height: 600
26
crop: true

Each size can have the following parameters:

  • width: Width in pixels
  • height: Height in pixels (set to 0 to maintain aspect ratio)
  • crop: Whether to crop the image to exact dimensions

Using Custom Image Sizes

Once custom image sizes are defined, you can use them in your theme:

1
<?php
2
// Get the featured image in the 'hero' size
3
the_post_thumbnail('hero');
4
5
// Get an image URL in the 'square' size
6
$image_url = wp_get_attachment_image_url($attachment_id, 'square');
7
8
// Using with Combo utility functions
9
cbo_acf_img($image, 'hero');
10
?>

Best Practices

  • Define image sizes based on how they'll be used in your theme
  • Use descriptive names for custom image sizes
  • Consider performance when defining image sizes
  • Use crop mode only when exact dimensions are required
  • Set height to 0 to maintain aspect ratio when only width matters