Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iamrealfarhanbd/d334960e31cd727582fbbbafc8bf342a to your computer and use it in GitHub Desktop.
Save iamrealfarhanbd/d334960e31cd727582fbbbafc8bf342a to your computer and use it in GitHub Desktop.
This PHP code snippet demonstrates how to use the ninja_tables_get_raw_table_data filter hook to modify data fetched from Ninja Tables. Specifically, it replaces thumbnail image URLs with their corresponding full-size image URLs in the image column of a Ninja Table with YourTableID. This customization ensures that larger images are used when dis…
add_filter('ninja_tables_get_raw_table_data', function ($data, $tableId) {
// Adjust this condition based on your target table ID
if ($tableId == YourTableID) { //Change YourTableID with your table ID
foreach ($data as &$row) {
foreach ($row as $key => $value) {
// Check if the value is an array with 'image_thumb' and 'image_full' keys
if (is_array($value) && isset($value['image_thumb']) && isset($value['image_full'])) {
// Replace the 'image_thumb' URL with the 'image_full' URL
$row[$key]['image_thumb'] = $value['image_full'];
}
}
}
}
return $data;
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment