What it does:
At product's create/edit page, in Data TAB, at image filemanager, you get 3 buttons:
(Browse Files | Clear Image | no_image.jpg)
The default behaviour now is to assign no_image.jpg, if no image is assigned manually. If Clear Image is pressed it assigns nothing (as it was by default).
Attachments
no image fix 1.1
PeoplesCode.com
Επίσημος Αντιπρόσωπος OpenCart | Extensions - Φιλοξενία - Αναβάθμιση - Τεχνική Υποστήριξη OpenCart
Opencart-Hellas.gr - Η Ελληνική κοινότητα του Opencart
Πλήρης Ελληνική μετάφραση OpenCart
Thanks for your help.
Matt
It could be done easily, but it would require modding a lot of files. A better and cleaner way to do it, is to ask the developer of the import extension you use, to add a couple of lines of code to implement the logic you require.Isn't there some sort of way to just automatically reference the no_image.jpg when a picture is missing? Then, when the picture is added, it is replaced automatically?
PeoplesCode.com
Επίσημος Αντιπρόσωπος OpenCart | Extensions - Φιλοξενία - Αναβάθμιση - Τεχνική Υποστήριξη OpenCart
Opencart-Hellas.gr - Η Ελληνική κοινότητα του Opencart
Πλήρης Ελληνική μετάφραση OpenCart
I am also after something like this. I have imported approx 10,000 products with the part number as the image name. When I sort out the images and upload them to my server they will just show up without having to go through each product.matt71 wrote:This is an interesting concept as I have been looking for a fix to this problem that will work with 1.5.4.1. However, for those of us that use an upload tool (such as Total Import Pro), this isn't an ideal solution. Isn't there some sort of way to just automatically reference the no_image.jpg when a picture is missing? Then, when the picture is added, it is replaced automatically?
Thanks for your help.
Matt
In the meantime whilst there is no image I would like to have the default no-image to be displayed.
Can any body help?
You can implement it at a global level in catalog/model/tool/image.php or in specific areas at the template level.
A) Global method
You can edit line 16 in catalog/model/tool/image.php
Change this:
Code: Select all
return;
Code: Select all
//return;
$filename = "data/no_image.jpg";
(In the above example "no_image.jpg" resides inside "image/data/" folder. If it resides in "image" folder, omit the "data" path.)
B) Template method
This is also easy to implement but the actual code implementation depends on your template ...
This example illustrates how it could be done in the default theme of Opencart 1.5.5.1 at product's page
Open catalog/view/theme/default/template/product/product.tpl
You modify the line 23 of the following code:
Code: Select all
<?php if ($thumb || $images) { ?>
<div class="left">
<?php if ($thumb) { ?>
<div class="image"><a href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>" class="colorbox"><img src="<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" id="image" /></a></div>
<?php } ?>
<?php if ($images) { ?>
<div class="image-additional">
<?php foreach ($images as $image) { ?>
<a href="<?php echo $image['popup']; ?>" title="<?php echo $heading_title; ?>" class="colorbox"><img src="<?php echo $image['thumb']; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" /></a>
<?php } ?>
</div>
<?php } ?>
</div>
<?php } ?>
Code: Select all
<?php } ?>
Code: Select all
<?php } else { ?>
<div class="left">
<div class="image"><img src="image/data/no_image.jpg" title="No Image" alt="No Image" id="image" style="width:228px;height:228px;" /></a></div>
</div>
<?php } ?>
Similar code can be added to any other template files you require the same behaviour.
PeoplesCode.com
Επίσημος Αντιπρόσωπος OpenCart | Extensions - Φιλοξενία - Αναβάθμιση - Τεχνική Υποστήριξη OpenCart
Opencart-Hellas.gr - Η Ελληνική κοινότητα του Opencart
Πλήρης Ελληνική μετάφραση OpenCart
Code: Select all
if(file_exists(DIR_IMAGE . 'no_image.jpg')) {
$filename = 'no_image.jpg';
} else {
$filename = 'no_image.png';
}
Whatever you makes you happy ... the outcome of both approaches is exactly the same. The code you posted just adds another check whether the file name 'no_image.jpg' exists, otherwise it assigns 'no_image.png' . This is an overkill since you are the one doing the mod and you already know the file's name and that it exists.Thanks for the reply. After posting I found this by Jay and it seems to do the job. Similar to your method A. Replacing the same line as your code
PeoplesCode.com
Επίσημος Αντιπρόσωπος OpenCart | Extensions - Φιλοξενία - Αναβάθμιση - Τεχνική Υποστήριξη OpenCart
Opencart-Hellas.gr - Η Ελληνική κοινότητα του Opencart
Πλήρης Ελληνική μετάφραση OpenCart
Mass update product descriptions/Hromadná změna popisků zboží
You could do that if you like, but its messy and you still have to edit OpenCart's code.cannot you set up the default value of column in database?
First you change the default value of image column to "no_image.jpg" at the database structure.
Then you have to change the way the model checks for the image file. Otherwise it will override your default database setting with empty.
in admin/model/catalog/product.php:8
Change this:
Code: Select all
if (isset($data['image'])) {
$this->db->query("UPDATE " . DB_PREFIX . "product SET image = '" . $this->db->escape(html_entity_decode($data['image'], ENT_QUOTES, 'UTF-8')) . "' WHERE product_id = '" . (int)$product_id . "'");
}
Code: Select all
if (isset($data['image']) && $data['image'] != false) {
$this->db->query("UPDATE " . DB_PREFIX . "product SET image = '" . $this->db->escape(html_entity_decode($data['image'], ENT_QUOTES, 'UTF-8')) . "' WHERE product_id = '" . (int)$product_id . "'");
}
PeoplesCode.com
Επίσημος Αντιπρόσωπος OpenCart | Extensions - Φιλοξενία - Αναβάθμιση - Τεχνική Υποστήριξη OpenCart
Opencart-Hellas.gr - Η Ελληνική κοινότητα του Opencart
Πλήρης Ελληνική μετάφραση OpenCart
does not mysql write default value if the column is set to null?
Mass update product descriptions/Hromadná změna popisků zboží
Sure, that works too.what about !empty?
Yes, but the above code actually produces empty, and not null, if an image is not set (I edited my last post to reflect this).does not mysql write default value if the column is set to null?
PeoplesCode.com
Επίσημος Αντιπρόσωπος OpenCart | Extensions - Φιλοξενία - Αναβάθμιση - Τεχνική Υποστήριξη OpenCart
Opencart-Hellas.gr - Η Ελληνική κοινότητα του Opencart
Πλήρης Ελληνική μετάφραση OpenCart
Users browsing this forum: No registered users and 41 guests