• Home
  • Programming
    • API
      • Google
    • Javascript
    • Php
    • Server
  • CMS
    • Magento
    • Yahoo! Store

Loop Spreadsheet and Update image height/width

Friday, 14 May 2021 19:13
Tim Ramsey
0 Comments
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load(storage_path('file.xlsx'));
        $worksheet = $spreadsheet->getActiveSheet();
        $highestRow = $worksheet->getHighestRow();
        for($row = 1; $row <= $highestRow; ++$row){;
            $value = $worksheet->getCellByColumnAndRow(23, $row)->getValue();
            $doc = new \DOMDocument();
            @$doc->loadHTML('<node>' . $value .'</node>', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
            $images = $doc->getElementsByTagName('img');
            foreach ($images as $image) {
                if(!$image->hasAttribute('height') || $image->hasAttribute('width')){
                    $src = $image->getAttribute('src');
                    list($width, $height, $type, $attr) = @getimagesize($src);
                    if((int) $height > 0) {
                        $image->setAttribute('height', $height);
                    }
                    if((int) $width > 0) {
                        $image->setAttribute('width', $width);
                    }
                }
            }
            $document = utf8_decode($doc->saveHTML($doc->documentElement));
            $worksheet->setCellValueByColumnAndRow(23, $row, str_replace(array('<node>','</node>') , '' , $document));
        }
        $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
        $writer->save(storage_path('file-new.xlsx'));

Github permission denied from cPanel

Tuesday, 29 December 2020 16:45
Tim Ramsey
0 Comments

For some reason cPanel private keys are needing to be manually added for it to connect to github properly

1
ssh-add /home/your_user_name/.ssh/you_private_key_file

Also, I ran into an issue where the ssh-agent was not running and needed to be restarted with

1
ssh-agent bash

Magento 2 Remove version signing static files

Monday, 09 November 2020 13:23
Tim Ramsey
0 Comments
1
INSERT INTO core_config_data (scope, scope_id, path, value) VALUES ('default', 0, 'dev/static/sign', '0');

Composer Memory Limit Issues when updating/installing

Wednesday, 09 September 2020 12:34
Tim Ramsey
0 Comments

If you run into memory limit issues while trying to use composer, you can disable(or limit to a higher limit e.g. 1024M) with via the method below.

1
php -d memory_limit=-1 `which composer` require composer/modulename

Page 3 of 15

  • Previous
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • …
  • 15
  • Next

Categories

  • CMS
    • Magento
    • Shopify
    • Yahoo! Store
  • Programming
    • API
      • Google
    • Javascript
    • Php
    • Server
    • SVN
  • VOIP

Recent Posts

  • How to write to Google Sheet with API in PHP
  • How to Migrate FreePBX server to a new server
  • Unifi Controller Java CPU 100%
  • Update Unifi Controller on Linux
  • Code Signing Desktop App