@DrupalGideon - There were 2 issues in the script you shared.
- The insert qu...

Contribution Date
Technology
Contribution Project
Contribution Details

@DrupalGideon - There were 2 issues in the script you shared.
- The insert query was inserting the ID in the style_name column.
- There was undefined variable($t) in drupal_set_message.

Below is the updated script:

$styles = db_select('image_styles', 'styles') ->fields('styles', array('name', 'isid')) ->execute() ->fetchAllKeyed(); $crops = db_select('epsacrop_files', 'ef') ->fields('ef', array('fid', 'coords')) ->execute() ->fetchAll(); foreach ($crops as $crop) { $fid = $crop->fid; $coords = drupal_json_decode(unserialize($crop->coords)); if (isset($coords[$fid])) { foreach ($coords[$fid] as $epsaid => $data) { $array = explode('-', $epsaid, 2); if ($array[0] == 'epsacrop') { array_shift($array); } $name = implode('-', $array); if (empty($styles[$name])) { continue; } try { $query = db_insert('manualcrop') ->fields(array( 'fid' => $fid, 'style_name' => $name, 'x' => $data['x'], 'y' => $data['y'], 'width' => $data['w'], 'height' => $data['h'], )) ->execute(); } catch (Exception $e) { drupal_set_message(t('An error occurred updating to Manual Crop. Sorry.'), 'error'); } } } }
Issue Status
Active
Contribution Author
Files count
0
Patches count
0