Jump to content
Budrys

Images links

Recommended Posts

Hello.

 

Is there any way to list links to all images in PS?

Share this post


Link to post
Share on other sites

What kind of question is that ?
Do you want to show all links somewhere or do you want to save all links to a file?
Specify your question, idea.

Share this post


Link to post
Share on other sites

I would like to Save links to all images. 

 

I need to find them and Use some image optimalization module. 

Share this post


Link to post
Share on other sites
Posted (edited)

OK.

Here is an example of displaying all full links to the images.

<?php
  ini_set('display_errors', 1);
  ini_set('display_startup_errors', 1);
  error_reporting(E_ALL);

  include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.inc.php');
  include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'settings.inc.php');
  include(dirname(__FILE__) . '/init.php');
  
  $get_images = Db::getInstance()->ExecuteS('select * from '._DB_PREFIX_.'image order by id_product asc;');
  $get_images_type = Db::getInstance()->ExecuteS('select * from '._DB_PREFIX_.'image_type order by id_image_type asc;');
  
  foreach ($get_images as $get_image) {
      $image = new Image($get_image['id_image']);
      $image_url = Tools::getHttpHost(true).__PS_BASE_URI__.'img/p/'.$image->getExistingImgPath().".jpg";
      echo $image_url.'<br />';
      
      foreach ($get_images_type as $get_image_type) {
          $image_url = Tools::getHttpHost(true).__PS_BASE_URI__.'img/p/'.$image->getExistingImgPath().'-'.$get_image_type['name'].".jpg";
          echo $image_url.'<br />';
      }
  }
 

 

Here is an example of saving all full links to images.

<?php
  ini_set('display_errors', 1);
  ini_set('display_startup_errors', 1);
  error_reporting(E_ALL);

  include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.inc.php');
  include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'settings.inc.php');
  include(dirname(__FILE__) . '/init.php');
  
  $images_path = '';
  $get_images = Db::getInstance()->ExecuteS('select * from '._DB_PREFIX_.'image order by id_product asc;');
  $get_images_type = Db::getInstance()->ExecuteS('select * from '._DB_PREFIX_.'image_type order by id_image_type asc;');
  
  foreach ($get_images as $get_image) {
      $image = new Image($get_image['id_image']);
      $image_url = Tools::getHttpHost(true).__PS_BASE_URI__.'img/p/'.$image->getExistingImgPath().".jpg";
      $images_path .= $image_url."\r\n";
      
      foreach ($get_images_type as $get_image_type) {
          $image_url = Tools::getHttpHost(true).__PS_BASE_URI__.'img/p/'.$image->getExistingImgPath().'-'.$get_image_type['name'].".jpg";
          $images_path .= $image_url."\r\n";
      }
  }
  
  file_put_contents('image-list.txt',$images_path);
  echo 'Done';

 

If I helped you, rate me 😉

spacer.png

Edited by D. Tengler (see edit history)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More