Can someone suggest how to change default image for products whose image is not available in version 4.3.7?
Thanks
YPG
Can someone suggest how to change default image for products whose image is not available in version 4.3.7?
Thanks
YPG
You can use the following guide to change corresponding image in the glyphs font:
Ugh, I don't understand why they did that silly glyphs font thing for the "no image" image. A pain to change and the cursor doesn't turn to a hand in the product list when its over the "no image" image. It finally annoyed me enough that I decided to just get rid of the glyph with a mod. Very limited testing at this point.
Put the image you want for your "no image" image in images/detailed/0/no_image.jpg
Then put this in your my_changes addon.
app/addons/my_changes/init.php
if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }fn_register_hooks(
‘get_image_pairs_post’
);
app/addons/my_changes/func.php
if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }// Substitiute a “no image” image when a product doesn’t have an image
function fn_my_changes_get_image_pairs_post($object_ids, $object_type, $pair_type, $get_icon, $get_detailed, $lang_code, &$pairs_data) {
static $no_image_x, $no_image_y;
if ( $object_type == ‘product’ && $pair_type == ‘M’ ) {
foreach ((array) $object_ids as $object_id) {
if ( empty($pairs_data[$object_id]) ) {
$pairs_data[$object_id][0] = array(
‘pair_id’ => 0,
‘image_id’ => 0,
‘detailed_id’ => 0,
‘position’ => 1,
);
$pair = array(
‘pair_id’ => 0,
‘object_id’ => 0,
‘object_type’ => ‘product’,
‘image_id’ => 0,
‘detailed_id’ => 0,
‘type’ => ‘M’,
‘position’ => 1,
‘image_path’ => ‘no_image.jpg’,
‘alt’ => fn_get_lang_var(‘no_image’),
‘image_x’ => 0,
‘image_y’ => 0,
‘images_image_id’ => 0,
‘absolute_path’ => ‘’,
‘https_image_path’ => ‘’,
‘http_image_path’ => ‘’,
‘relative_path’ => ‘’
);
$pairs_data[$object_id][0][‘detailed’] = fn_attach_absolute_image_paths($pair, ‘detailed’);
if ( empty($no_image_x) ) {
$image_size = getimagesize($pairs_data[$object_id][0][‘detailed’][‘absolute_path’]);
$no_image_x = $image_size[0];
$no_image_y = $image_size[1];
}
$pairs_data[$object_id][0][‘detailed’][‘image_x’] = $no_image_x;
$pairs_data[$object_id][0][‘detailed’][‘image_y’] = $no_image_y;
}
}
}
}
Ugh, I don't understand why they did that silly glyphs font thing for the "no image" image. A pain to change and the cursor doesn't turn to a hand in the product list when its over the "no image" image. It finally annoyed me enough that I decided to just get rid of the glyph with a mod. Very limited testing at this point.
Put the image you want for your "no image" image in images/detailed/0/no_image.jpg
Then put this in your my_changes addon.
app/addons/my_changes/init.php
if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }fn_register_hooks(
‘get_image_pairs_post’
);
app/addons/my_changes/func.php
if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }// Substitiute a “no image” image when a product doesn’t have an image
function fn_my_changes_get_image_pairs_post($object_ids, $object_type, $pair_type, $get_icon, $get_detailed, $lang_code, &$pairs_data) {
static $no_image_x, $no_image_y;
if ( $object_type == ‘product’ && $pair_type == ‘M’ ) {
foreach ((array) $object_ids as $object_id) {
if ( empty($pairs_data[$object_id]) ) {
$pairs_data[$object_id][0] = array(
‘pair_id’ => 0,
‘image_id’ => 0,
‘detailed_id’ => 0,
‘position’ => 1,
);
$pair = array(
‘pair_id’ => 0,
‘object_id’ => 0,
‘object_type’ => ‘product’,
‘image_id’ => 0,
‘detailed_id’ => 0,
‘type’ => ‘M’,
‘position’ => 1,
‘image_path’ => ‘no_image.jpg’,
‘alt’ => fn_get_lang_var(‘no_image’),
‘image_x’ => 0,
‘image_y’ => 0,
‘images_image_id’ => 0,
‘absolute_path’ => ‘’,
‘https_image_path’ => ‘’,
‘http_image_path’ => ‘’,
‘relative_path’ => ‘’
);
$pairs_data[$object_id][0][‘detailed’] = fn_attach_absolute_image_paths($pair, ‘detailed’);
if ( empty($no_image_x) ) {
$image_size = getimagesize($pairs_data[$object_id][0][‘detailed’][‘absolute_path’]);
$no_image_x = $image_size[0];
$no_image_y = $image_size[1];
}
$pairs_data[$object_id][0][‘detailed’][‘image_x’] = $no_image_x;
$pairs_data[$object_id][0][‘detailed’][‘image_y’] = $no_image_y;
}
}
}
}
As I was still testing on new installation, I just gave it a try. The solution is PERFECT!
Thank you very much.
YPG
Great idea. How can this be amended so that it shows the no_image.jpg when a link exists in the database but the file linked cannot be found?
That is my situation and the current code is not working for me. Cleared cache, even restarted apache.
Cheers
Pete
Great idea. How can this be amended so that it shows the no_image.jpg when a link exists in the database but the file linked cannot be found?
That is my situation and the current code is not working for me. Cleared cache, even restarted apache.
Cheers
Pete
No, it won't work for that case. Not sure how you ended up that way but you could try changing in the above code
if ( empty($pairs_data[$object_id]) ) {
to
if ( empty($pairs_data[$object_id]) || !file_exists($pairs_data[$object_id][0]['detailed']['absolute_path']) ) {