Mark Posted September 14, 2019 Posted September 14, 2019 Hi around the time I updated to 1.1.0 many images became unusable by the system and now just have camera image placeholders throughout the site. Uploading new replacement images doesn't help. Ive tried regenerating thumbnails and the .htaccess file The process is that Im uploading product images, they upload fine, but then show as camera image placeholders in the back office. Sometimes they appear fine on the front office, sometimes not. Thinking its possibly something to do with Image Generation, Ive attached two pictures here of my image management section
0 zen Posted September 18, 2019 Posted September 18, 2019 I gave you my help in PV but you canceled it.. so what to do ?
0 SLiCK_303 Posted September 18, 2019 Posted September 18, 2019 (edited) @Mark, you are correct in what you are doing. You have a problem you cant figure out, you goto the forums and try and get help. Keep up the good fight! You'll get this figured out.... Edited September 18, 2019 by SLiCK_303
0 datakick Posted September 18, 2019 Posted September 18, 2019 I've just checked @Traumflug's commit, and it did not fix the problem at hand. @Mark edit file /classes/ImageType.php, find function getFormatedName, and insert following code just before // Give up searching: // if $name contains _default suffix, ie. home_default then try to resolve the name without this suffix $pos = strpos($name, '_default'); if ($pos === strlen($name) - 8) { return static::getFormatedName(substr($name, 0, $pos)); } The result should looks like this:
0 SLiCK_303 Posted September 18, 2019 Posted September 18, 2019 prior to 1.1.0....... I always assumed the _default part of the image name was referring to the theme's name, guess I was wrong... 😉
0 Mark Posted September 18, 2019 Author Posted September 18, 2019 I told why I cancelled your back office access @zen and you seemed fine with that at the time. It was cancelled because Traumflug was working on the code to fix it for everyone and there would be no need for you or I to try and change the back office or codebase when the proper solution was close at hand. Within hours of that, Traumflug did correct the code and it was the right decision to not spend time trying to change the codebase or back office settings adhoc in a potentially hazardous fashion. Despite having done a bleeding edge update yesterday @datakickmy ImageType.php file doesnt resemble yours. This is what I have <?php /** * 2007-2016 PrestaShop * * thirty bees is an extension to the PrestaShop e-commerce software developed by PrestaShop SA * Copyright (C) 2017-2018 thirty bees * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to https://www.thirtybees.com for more information. * * @author thirty bees <[email protected]> * @author PrestaShop SA <[email protected]> * @copyright 2017-2018 thirty bees * @copyright 2007-2016 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * PrestaShop is an internationally registered trademark & property of PrestaShop SA */ /** * Class ImageTypeCore * * @since 1.0.0 */ class ImageTypeCore extends ObjectModel { // @codingStandardsIgnoreStart /** * @var array Image types cache */ protected static $images_types_cache = []; /** @var array $images_types_name_cache */ protected static $images_types_name_cache = []; /** @var string Name */ public $name; /** @var int Width */ public $width; /** @var int Height */ public $height; /** @var bool Apply to products */ public $products; /** @var int Apply to categories */ public $categories; /** @var int Apply to manufacturers */ public $manufacturers; /** @var int Apply to suppliers */ public $suppliers; /** @var int Apply to scenes */ public $scenes; /** @var int Apply to store */ public $stores; // @codingStandardsIgnoreEnd /** * @see ObjectModel::$definition */ public static $definition = [ 'table' => 'image_type', 'primary' => 'id_image_type', 'fields' => [ 'name' => ['type' => self::TYPE_STRING, 'validate' => 'isImageTypeName', 'required' => true, 'size' => 64], 'width' => ['type' => self::TYPE_INT, 'validate' => 'isImageSize', 'required' => true], 'height' => ['type' => self::TYPE_INT, 'validate' => 'isImageSize', 'required' => true], 'categories' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'], 'products' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'], 'manufacturers' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'], 'suppliers' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'], 'scenes' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'], 'stores' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'], ], ]; protected $webserviceParameters = []; /** * Returns image type definitions * * @param string|null $type Image type * @param bool $orderBySize * * @return array Image type definitions * @throws PrestaShopDatabaseException * * @since 1.0.0 * @version 1.0.0 Initial version * @throws PrestaShopException */ public static function getImagesTypes($type = null, $orderBySize = false) { // @codingStandardsIgnoreStart if (!isset(static::$images_types_cache[$type])) { $query = (new DbQuery()) ->select('*') ->from('image_type'); if (!empty($type)) { $query->where('`'.bqSQL($type).'` = 1'); } if ($orderBySize) { $query->orderBy('`width` DESC, `height` DESC, `name` ASC'); } else { $query->orderBy('`name` ASC'); } static::$images_types_cache[$type] = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query); } return static::$images_types_cache[$type]; // @codingStandardsIgnoreEnd } /** * Check if type already is already registered in database * * @param string $typeName Name * * @return int Number of results found * * @throws PrestaShopDatabaseException * @throws PrestaShopException * @since 1.0.0 * @version 1.0.0 Initial version */ public static function typeAlreadyExists($typeName) { if (!Validate::isImageTypeName($typeName)) { die(Tools::displayError()); } Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( (new DbQuery()) ->select('`id_image_type`') ->from('image_type') ->where('`name` = \''.pSQL($typeName).'\'') ); return Db::getInstance()->NumRows(); } /** * @param string $name * * @return string * * @throws PrestaShopDatabaseException * @throws PrestaShopException * @since 1.0.0 * @version 1.0.0 Initial version */ public static function getFormatedName($name) { $themeName = Context::getContext()->shop->theme_name; $nameWithoutThemeName = str_replace(['_'.$themeName, $themeName.'_'], '', $name); //check if the theme name is already in $name if yes only return $name if (strstr($name, $themeName) && static::getByNameNType($name)) { return $name; } elseif (static::getByNameNType($nameWithoutThemeName.'_'.$themeName)) { return $nameWithoutThemeName.'_'.$themeName; } elseif (static::getByNameNType($themeName.'_'.$nameWithoutThemeName)) { return $themeName.'_'.$nameWithoutThemeName; } else { return $nameWithoutThemeName.'_default'; } } /** * Finds image type definition by name and type * * @param string $name * @param string $type * * @param int $order * * @return bool|mixed * @throws PrestaShopDatabaseException * @throws PrestaShopException * @since 1.0.0 * @version 1.0.0 Initial version */ public static function getByNameNType($name, $type = null, $order = 0) { static $isPassed = false; // @codingStandardsIgnoreStart if (!isset(static::$images_types_name_cache[$name.'_'.$type.'_'.$order]) && !$isPassed) { $results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT * FROM `'._DB_PREFIX_.'image_type`'); $types = ['products', 'categories', 'manufacturers', 'suppliers', 'scenes', 'stores']; $total = count($types); foreach ($results as $result) { foreach ($result as $value) { for ($i = 0; $i < $total; ++$i) { static::$images_types_name_cache[$result['name'].'_'.$types[$i].'_'.$value] = $result; } } } $isPassed = true; } $return = false; if (isset(static::$images_types_name_cache[$name.'_'.$type.'_'.$order])) { $return = static::$images_types_name_cache[$name.'_'.$type.'_'.$order]; } // @codingStandardsIgnoreEnd return $return; } }
0 Mark Posted September 18, 2019 Author Posted September 18, 2019 (edited) Note for anyone looking at my site and seeing I have images: I have temporarily reverted to Stable version of 1.1.0 which does present most but not all of the images while we complete this last piece of the puzzle, in order that customers, in the main, can do their thing.... Edited September 18, 2019 by Mark
0 Traumflug Posted September 18, 2019 Posted September 18, 2019 2 hours ago, datakick said: I've just checked @Traumflug's commit, and it did not fix the problem at hand. Well, it fixed the problem I found in my development installation. Looks like there's more than one problem involved here. Or I fixed something else, not the issue here.
0 datakick Posted September 18, 2019 Posted September 18, 2019 @Mark from the code you posted it looks like you downgraded to bleeding edge of 1.0.x branch, instead of bleeding edge of 1.1.x. Make sure you choose the correct version 1
0 Traumflug Posted September 18, 2019 Posted September 18, 2019 Looking at this page, one image is missing: https://product.solutions.org.nz/remote-car-alarm-with-central-locking-and-engine-disable Digging a bit deeper, this is the image URL: https://product.solutions.org.nz/194-community-theme-default_cart_default/remote-car-alarm-with-central-locking-and-engine-disable.jpg This URL looks fine to me. Shop is apparently using theme community-theme-default, this theme has the old image type names (with _default), so that's what's expected. Also, some other images work, which makes a glitch in image finding unlikely. Broken code usually applies to all images, not just a few. I'd start looking at which images are actually on disk. This image should be in img/p/1/9/4/ and next to index.php and the original file, 194.jpg, there should be one additional file for each image type. Similar to this (this is for image no. 21): 21-community-theme-default_cart_default.jpg 21-community-theme-default_home_default.jpg 21-community-theme-default_home_default_smaller.jpg 21-community-theme-default_home_default_smallest.jpg 21-community-theme-default_large_default.jpg 21-community-theme-default_medium_default.jpg 21-community-theme-default_small_default.jpg 21-community-theme-default_thickbox_default.jpg 21.jpg 21-Niara_cart.jpg 21-Niara_home.jpg 21-Niara_home_smaller.jpg 21-Niara_home_smallest.jpg 21-Niara_large.jpg 21-Niara_medium.jpg 21-Niara_small.jpg 21-Niara_thickbox.jpg index.php
0 Traumflug Posted September 18, 2019 Posted September 18, 2019 P.S.: I'd also download a few images and open them in an image viewer to find out whether they're actually JPEGs (or PNGs with suffix .jpg). I've seen shop installations where properly named files were there, but none of them being actual images.
0 Mark Posted September 18, 2019 Author Posted September 18, 2019 (edited) Thanks @datakick I have now updated to Bleeding Edge 1.1.0 , great spotting. Things seem to ok at first glance at the moment, and images that werent working before under Stable1.1.0 are now there Now I'll do what @Traumflugsuggests and look closely at any remaining problem images and replace them and look for anything else. Thank you all. Brilliant Core Updater process by the way, love that its so easy to change versions. Edited September 18, 2019 by Mark
0 datakick Posted September 19, 2019 Posted September 19, 2019 8 hours ago, Traumflug said: Well, it fixed the problem I found in my development installation. Looks like there's more than one problem involved here. Or I fixed something else, not the issue here. @Traumflug you are right. Your commit fixes the problem if you use .jpg / .png files. I'm using .webp and for those the code in PageNotFoundController does not work. I've created the pull request to add .webp support: https://github.com/thirtybees/thirtybees/pull/1063 I have also reopened my original pull request https://github.com/thirtybees/thirtybees/pull/1057. It is somewhat redundant now, but I still think it's a good to have. Let me explain what happens if some module wrongly uses hardcoded image type 'home_default': Current situation: the html output will contain image link in a format 'http://domain.com/111-home_default/product-name.jpg' because home_default type does not exists, this request will be handled by PageNotFoundController controller will be able to re-map image type 'home_default' to 'home', and return correct image With my pull request: the html output will already contain correct image link: 'http://domain.com/111-home/product-name.jpg' if image exists, apache/nginx will return it directly without involving php So, basically, this pull request saves some php processing time, and allows for better static assets optimization 1
0 loetje88 Posted March 28, 2021 Posted March 28, 2021 2 years later.... Just installed tb 1.1, which installs the niary theme and default theme on standard. So far so good. But, i want to work with the panda theme, tb version. As soon as i upload the panda theme, the problem persists wqith empty backoffice images because it still links to the old (default or niara) theme. i have tried everything i can think of, replace images, re generate images, delete cache, enter new images - nothing works. Any one can point me in the right direction?
0 Sigi Posted March 29, 2021 Posted March 29, 2021 try to update to version 1.2.x since 1.1.0 there have been a lot of changes
Question
Mark
Hi around the time I updated to 1.1.0 many images became unusable by the system and now just have camera image placeholders throughout the site.
Uploading new replacement images doesn't help.
Ive tried regenerating thumbnails and the .htaccess file
The process is that Im uploading product images, they upload fine, but then show as camera image placeholders in the back office.
Sometimes they appear fine on the front office, sometimes not.
Thinking its possibly something to do with Image Generation, Ive attached two pictures here of my image management section
Top Posters For This Question
15
11
10
10
Popular Days
Sep 16
21
Sep 18
18
Sep 14
13
Sep 15
5
Top Posters For This Question
Traumflug 15 posts
zen 11 posts
datakick 10 posts
Mark 10 posts
Popular Days
Sep 16 2019
21 posts
Sep 18 2019
18 posts
Sep 14 2019
13 posts
Sep 15 2019
5 posts
Popular Posts
Occam
This already has a tiny disadvantage: the Niara theme won't find the images afterwards, because in the theme as well as in many modules the picture format names are hard coded - no matter what @zen be
lesley
@Occam Good point. I think we are going to have to figure out a perm fix for this. That is something we did not take into account.
datakick
Yes, the best solution would be to fix all modules. Unfortunately that's not realistic solution. There are many modules that uses hardcoded `large_default` or `home_default` image types. These modules
Posted Images
64 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now