Oscommerce display default product image and prevent it from deletion - image

I am working on an oscommerce project where i want to display default product image (i.e no image available) if product image is not uploaded.And even i want it to prevent from deletion.I have tried to upload product not available image for 2-3 products but when deleting products i.e final last product image also gets deleted from the folder.I want that if user doesn't upload image then by default no_product_available.jpg should be shown in CATEGORIES.php as well as PRODUCT_INFO.php.
Can anyone help me to do this ? I am using oscommerce default template.

I think I understand what you would like to do... Pretty much you're saying that if someone doesn't upload an image with a product or category then you would like the no_image.jpg image to be displayed instead of nothing being displayed. Additionally, you would like for the no_image.jpg to not be deleted if the category or product is deleted. I think I can help with this...
You need to modify the tep_image() function located in catalog/includes/function/html_output.php
Replace...
if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
return false;
}
With...
if (!is_file($src)) {
$src = "images/no_image.jpg";
}
Now when you use the tep_image() function if no image was uploaded or if the file is specified but missing from the server then no_image.jpg will be displayed. When the category or product is deleted the is no_image.jpg file is not associated with the category or product so nothing is deleted. Obviously, replace "images/no_image.jpg" with the correct location and filename for your default no image file. Also, you may wish to modify the code above to get the specific behavior you want but this is a good starting point to achieve what you want.
The index.php and product_info.php pages use tep_image()... So, you should be all set there. If you're making your own page or modifying an existing one then you would of course need to use the tep_image() function to get the no_image.jpg output functionality. The parameters for tep_image() are...
tep_image($src, $alt = '', $width = '', $height = '', $parameters = '')
UPDATE:
tep_image should already be in both the index.php (the page that generates the category/product list pages) and product_info.php. Just open either file and search for "tep_image" without quotes or parentheses. You should find several instances in both files. Examine the code to understand what has already been done so that when you add a new image you understand the correct syntax.
Pretty much just place tep_image where you want your new image to show up on the page. You need to be familiar with HTML and PHP to read through the page and determine where you want the image placed. If you want to move the current image then you might be able to just cut and paste the current tep_image code to a your new location.
You can also use "Inspect Element" in Chrome in the right click menu to help determine location. Just open the page you want to add an image to and right click in the area you want to add an image to. Then look at the surrounding page source code. Now you have an idea what to look for in the PHP file.
BTW, the index.php page is a little tricky. That page is responsible for the homepage, category listing pages, and product listing pages. Also, there are several other module PHP pages that are Included (so the source code is in a different file that you'll need to track down if that's the area you want to add the image to). Make sense ;-)
Give it a try and write back with what want specifically and you did to achieve it. There are lots of people that have helped me in the past. So, I'm happy to help.

Related

How to process image width/height in TYPO3?

I built a website in plain html/css with my own design. Now I need to put this website in TYPO3 CMS 9.5.4. Unfortunately it's my first time working with TYPO3 and I don't really know what I'm doing.
What I got so far:
Most of the website is already working fine. I included fluid_styled_content and my setup basically looks like this:
page = PAGE
page.1 = FLUIDTEMPLATE
page.1 {
file = fileadmin/sitedesign/Resources/Private/Templates/Page.html
variables {
content < styles.content.get
}
}
The Page.html file is basically my whole html template and I put
{content->f:format.raw()}
where I want my content.
All content I create in the backend is displayed as I want except of images.
My question:
I can display images by creating a "Text & Images" content element and adding the images in the "Images" tab. In the "Media Adjustments" section I can now set the width and height of each element and below I can choose the number of columns.
However these do not change anything in the source code of my website i.e. in the content variable, so all images are displayed in full size.
What can I do to make the width/height appear in the source code (ideally as width/height attribute of that element)?
Hey Erik and welcome to TYPO3. Usually TYPO3 will take care of the correct images sizes when using the default Content Elements (e.g. Text & Images). But TYPO3 requires ImageMagick or GraphicsMagick installed on the server to modify the pictures.
You can check out if your system matches all requirements using the "Environment" module in the TYPO3 backend (modules on the left side of the backend). Then you will see a function called "Image processing" which will test the required image functions of your server.

Joomla - use full article image instead of intro image

I wanted to ask if there is a possibility to force Joomla to use full article image if intro image is empty (everywhere where image should be visible).
Is there a setting for this? Is it a feature of a template or Joomla engine itself? Right now I always have to specify both of this images, cause if I specify one only full article image Joomla does not display miniature in many places. If I specify the other one miniature is there but when I enter article it is missing.
I always end up having to specify the same image twice. Is there any way around this?
Thanks
UPDATE1:
I ended up overwriting the template for article to display $images->intro_image whenever $images->image_fulltext is not available.
This solves my problems yet one joomla user tells me she is sure that they were able to do that before without any modifications in the template. So now I'm just wondering if there is a setting for this in Joomla Admin so that it does not have to be forced in template code
It turned out that each element of my page except full article used intro_image. So what I did was to copy out the part responsible for showing article into the html folder of my template and just added a php code to use intro image instead of fulltext image (if it is present). You basically need to change $image->fulltext to $image->intro_image in the condition. But remember to keep the original condition as an elseif condition if you want to be able to still use full text image

image display in drupal

i would like to create an image gallery on my homepage in drupal. Each image will have been uploaded by the user, and, as i understand it, will be saved in some image directory folder in drupal. My question concerns a recent tip i picked up in response to the general debate whether or not it is good to store images as blob in mysql. The tip was to store the filenames of the images in mysql so you can essentially still sort the files. I was wondering whether this would be possible even if the files url is in drupal so to speak. It should be possible shouldn't it? I new to programming you see and want to the images on my homepage to be periodically refreshed according to a define sorting function. I would greatly appreciate any response to this question. Cheers.
You can using content types and views module for create gallery in Drupal 7.
First create new content type with gallery name(admin/structure/types/add).
Then add a image field to gallery content type and save it.
If you want have thumbnail of image you should create a image style. for example create a image style with thumbnail_custom name and add suitable effect(admin/config/media/image-styles/add). You will use of this image style in views in the next step.
Then create a new view with gallery-view name. uncheck create a page, check create a block, enter block title and item per page you want(admin/structure/views/add).
In Filter criteria from block details add content type gallery.
In Fields add Content image that appears in node:gallery and select and select thumbnail_custom for image style option.
Save view.
This view block appears in Blocks section and you select region for it.
If you want this block appears only in the front page, in configuration of this block in the section pages of visibility settings check "Only the listed pages" option and then enter "<front>" phrase in textarea.

Magento - Where do I go to edit file that outputs the sitemap?

I would like to update the template that generates the google sitemap in Magento 1.5.
Reason being, Magento is using the URLKey (e.g. /my-jacket.html) and not the full URL with category (e.g. /outerwear/jackets/my-jacket.html).
I'm doing this in another place on the site (an .html sitemap) and it works great. When looping through products inside a category...
// get the categories for this product
$_categories = Mage::getModel('catalog/product')->load($product_id)->getCategoryIds();
$_category = Mage::getModel('catalog/category')->load($_categories[0]);
// build the URL path
$url = Mage::getUrl($_category->getUrlPath()).basename($_product->getUrlKey());
// only problem is this will be /category/category2.html/my-jacket.html
// so strip the .html and put it on the end
$url = str_replace(".html","" ,$url) . '.html';
It's ugly but works. Anyway, I want to do the same to the google sitemap that gets generated, but after much searching for where it is generated, I can't find it. Anyone point me in the right direction?
I'm fairly certain that there's no simple template to edit. The XML generating happens inside of a model, specifically: Mage_Sitemap_Model_Sitemap::generateXml().

Magento - adding a new field to the product options in admin

I'd like to add a new tab to the 'catalog->manage products->product information' page in the admin. Underneath the 'images' tab, I'd like to add a new tab for video, with a simple text input for adding a video url, which I can then grab for the frontend.
Anyone any ideas where the files are that I need to edit? I've been looking for the last couple hours with no joy. I found the list of current options in Mage_Catalog_Model_Resource_Eav_Mysql4_Setup but can't figure out how to add to them...
Seems it gets some from Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs. If I copy one of the tab sections here and change the title to Video, I can get it to display in the tabs on the left. But how do I then add the options for it?
What you are trying to do, from the sounds of it, is to create a custom field and add it to your catalog data. The good news is that you don't need to muck around in the PHP for that.
Head to Catalog -> Attributes -> Manage Attributes and create a new attribute for yourself called "Video URL" (or something to that effect). This will probably be a text field, and you may want to hide it from comparison on the frontend of the site (select "No" for all those boxes at the bottom of the form).
Once you've created an attribute, you will need to add it to an attribute set. If all your products are of one "type", and if you didn't create any other attribute sets, this should be only one step. Head to Catalog -> Attributes -> Manage Attribute Sets and create a "New Group" called "Video" and drag your new video url attribute into it. Save the attribute set and you should now have your new tab.
The only complication from what I read in your post could be positioning it underneath the images tab. Magento adds several tabs statically (the long way, in the PHP) and doesn't generally obey ordering of the tab groups. Consider the time tradeoff.
Hope that helps. Thanks,
Joe
Per your other comments, for the URLs a simple attribute would work but files would tend to be more difficult. To add a custom tab, as you said, you can edit (or in the case of a plugin, override) Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs::_prepareLayout and add your tab. You'll need to add a block or template to display your tab contents.
After that, you'll need to store the data somewhere. Looking in Adminhtml/controllers/ProductController, you should be able to hook into the catalog_product_prepare_save event to get data from $event->getRequest() and push it onto the product or save another entity as necessary.
I'm not sure how well file saving semantics would work on a product, so you may want to do your own data storage in the extension and then provide something like a getVideoForProduct method to retrieve it.
Then the only thing left to do is modify the catalog/product/view.phtml template file to include your thumbs and create a controller in your extension to provide a modal w/ the video (or do it in JS).
I know that's a bit of a general answer, but it's the rough path you would need to take for tabs. Let me know if any specific part of that is unclear.
Thanks,
Joe

Resources