Document library column width & image size
Document Library Pro will automatically size your columns for the best fit. There are several options to override this behavior and control the column widths, as well as the size of featured images in the table.
Document Library Pro will automatically calculate column widths, but you can override this using the
widths option. You need to enter a value for each column in your table – either a percentage, a pixel amount or the keyword “auto” to have the plugin calculate the width automatically.
For example, you might have 3 columns in your table: title, content and date - and you want to set the width of the title column to 20%, the content column to 50% and the date column to 30%. You can achieve this using this shortcode:
[doc_library columns="title,content,date" widths="20,50,30"].
If you wanted to set the width of the first column to 50px, and automatically size the other columns, then you can use:
[doc_library columns="title,content,date" widths="50px,auto,auto"]
By default, Document Library Pro will automatically calculate column widths to best fit your content in the space available. Set the
auto_width option to
false to disable this feature.
Column width problems
The widths option isn't working!
If the widths option isn't working, then it might be that you have set the width too narrow and the contents will no longer fit in the column. Instead of allowing it to look broken, the plugin will make the width wider so that the contents fit. Try increasing the width of the affected columns.
I have multiple tables on the same page, and the column widths are different in each table
The column widths are calculated automatically based on the information about each post in the current table. If you have more than one table on a page, you can use the widths option (above) to force the column widths to be the same for each table.
My column widths change when I move from one page to the next, or use the filters
This can happen if the contents of a column contains a different number of characters for each post. The width of each column of the table is calculated based on the current posts on that page of the table, so this might change when you perform a filter or go from one page to the next.
You can use the widths option (above) to force the columns to always be the same width.
image_size option controls the size of the image column if you are using this in your table. Defaults to
thumbnail. You can use any standard image size (thumbnail, medium, large or full), or one or two numbers to denote the exact width and height for the image.
For example, to use the
medium image size:
[doc_library columns="image,title,content" image_size="medium"]
For a square image 50 by 50 pixels:
[doc_library columns="image,title,content" image_size="50"]
For an image 50 pixels wide by 40 pixels high:
[doc_library columns="image,title,content" image_size="50x40"]
How to fix image size problems
Image sizing is very complex in WordPress, and can have unexpected results.
A few tips:
- Your images must be the correct proportion for your chosen image size. For example, if your images are square and you set
image_size="50x40"then the images will still appear square.
- If you're using the built-in image sizes (e.g. thumbnail, medium or large) then you can check their sizes in Settings → Media.
- It's possible that the width settings (see above) may be overriding your image sizes. For example, if you have set a fixed width for the image column and a specific image size then these options may conflict.
- If you're really struggling to get your images the correct size in the table then you can resize the original image to the correct size.