Hello wpDataTables Team,
I would like to suggest an improvement to the image display feature in wpDataTables.
Currently, wpDataTables can display images in a table when the field contains a direct image URL. This works well in many cases, but in WordPress development, images are often stored as attachment IDs rather than direct URLs. For example, custom tables, JetEngine CCTs, ACF fields, or other custom integrations may store the image source as a WordPress media attachment ID.
It would be very useful if wpDataTables could support displaying images when the field value is a WordPress attachment/post ID, not only a URL.
Suggested feature options:
Image source type
Add an option for image columns such as:
Image URL
WordPress Attachment ID
Image size selection
When using an attachment ID, allow users to choose a WordPress image size:
Thumbnail
Medium
Large
Full
Any registered custom image size
Custom image dimensions
Add controls for:
Custom width
Custom height
Max width
Max height
Aspect ratio / cropping control
Add layout options such as:
Keep original ratio
Square image
4:3
16:9
Custom ratio
Object fit: cover / contain
Fallback behavior
If the attachment ID is invalid or the image no longer exists, allow a fallback option:
Show empty cell
Show placeholder image
Show attachment ID as text
This would make wpDataTables much more flexible for WordPress-based projects where media is handled through the Media Library and stored as attachment IDs. It would also reduce the need for custom PHP callbacks or manually converting attachment IDs into URLs before displaying the table.
A possible implementation could use WordPress functions like:
wp_get_attachment_image_url($attachment_id, $image_size);
or:
wp_get_attachment_image($attachment_id, $image_size, false, [
‘class’ => ‘wpdatatable-image’,
‘style’ => ‘width:100px;height:100px;object-fit:cover;’
]);
This feature would be especially helpful for developers using wpDataTables with custom database tables, ACF, JetEngine, custom post meta, or other WordPress media-based workflows.
Thank you for considering this suggestion. I believe it would make the image column feature much more powerful and WordPress-friendly.
Best regards,
Ulyses