• Toll-free  888-665-8637
  • International  +1 717-220-0012
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Coleen
#1 Posted : Tuesday, October 23, 2007 10:49:21 AM(UTC)
Coleen

Rank: Member

Joined: 4/30/2007(UTC)
Posts: 383

Instead of having to upload each file indvidually within the system upload multiple files at one time.


I know it can be done via FTP but then the system doesn't "see" the files.
Cliff
#2 Posted : Tuesday, October 23, 2007 3:58:33 PM(UTC)
Cliff

Rank: Member

Joined: 5/24/2004(UTC)
Posts: 4,147

You mean, when you upload images to add to a product, for example, the file browser in BVC5 does not show the images you uploaded?
[email protected]
#3 Posted : Wednesday, October 24, 2007 6:46:02 PM(UTC)
bobn@laurastamm.net

Rank: Member

Joined: 6/6/2005(UTC)
Posts: 483

I think he is talking about files available for download using the download section of the edit product.

Bob Noble
birdsafe
#4 Posted : Thursday, October 25, 2007 6:46:47 AM(UTC)
birdsafe

Rank: Member

Joined: 2/21/2007(UTC)
Posts: 1,113

Actualy I take to mean that he wants to be able to upload all images related to creating a new product at once -- as it is you have to upload a small image, medium image, and then any larger/other images you might have.

I would love to see a utility like I had with SF -- I forget the developer's name right now -- where you have one image, and it automatically created and uploaded three separate sized images, plus had the option of creating a watermark
CorneliuTusnea
#5 Posted : Friday, October 26, 2007 12:22:59 AM(UTC)
CorneliuTusnea

Rank: Member

Joined: 8/17/2006(UTC)
Posts: 681

Joe,

I have a plugin for the Product page that allows you to select only ONE image in the Medium Image box.
When you save the product the plugin will automatically resize the image to a small image and save it as a small image, resize it to a medium image and save it to a medium image and then save the original one as the first additional image.
This improves the process of uploading images a lot as you never have to bother about creating the right images.
If you want I can publish this changes.

Corneliu.
http://www.bestgames.com.au
http://www.bestchess.com.au



BV Product Links, Details and Signatures: Improve your customer experience:

http://www.acorns.com.au/projects/bv/quicklink/

birdsafe
#6 Posted : Saturday, October 27, 2007 9:57:55 AM(UTC)
birdsafe

Rank: Member

Joined: 2/21/2007(UTC)
Posts: 1,113

That would be cool!
CorneliuTusnea
#7 Posted : Tuesday, October 30, 2007 8:34:04 AM(UTC)
CorneliuTusnea

Rank: Member

Joined: 8/17/2006(UTC)
Posts: 681

Ok,
Here we go. I hope i'm not missing any parts of it:
1. Products_Edit.aspx.vb, function Save Add the following line
' Corneliu - Build a Small Image if only a medium image exists
ProductUtils.BuildProductImages(p, Request.PhysicalApplicationPath)
Just before:
If String.IsNullOrEmpty(Me.SmallImageAlternateTextField.Text) Then
p.ImageFileSmallAlternateText = p.ProductName & " " & p.Sku
Else
p.ImageFileSmallAlternateText = Me.SmallImageAlternateTextField.Text
End If

2. Add this to your App_Code\ProductUtils.vb
Public Shared Function BuildProductImages(ByVal product As Catalog.Product, ByVal physicalRoot As String) As Boolean
If String.IsNullOrEmpty(product.ImageFileMedium) Then
Return False
End If

If String.IsNullOrEmpty(product.ImageFileSmall) Then
Dim newSmallImage As String = ResizeImage(product.ImageFileMedium, "_sm", physicalRoot, WebAppSettings.ImagesSmallWidth, WebAppSettings.ImagesSmallHeight)

If newSmallImage IsNot Nothing Then
product.ImageFileSmall = newSmallImage
End If
End If

Dim medImageFileName As String = GetFullPhysicalFileName(physicalRoot, product.ImageFileMedium)

' check if the medium image is "too large"
Dim medImageInfo As ImageInfo = ImageHelper.GetImageInformation(medImageFileName)
If medImageInfo.Height > WebAppSettings.ImagesMediumHeight Or medImageInfo.Width > WebAppSettings.ImagesMediumWidth Then
' resize this image
Dim oldMedImage As String = product.ImageFileMedium
Dim newMedImage As String = ResizeImage(oldMedImage, "_med", physicalRoot, WebAppSettings.ImagesMediumWidth, WebAppSettings.ImagesMediumHeight)

If newMedImage IsNot Nothing Then
product.ImageFileMedium = newMedImage

Dim shouldAdd As Boolean = True
If product.AdditionalImages IsNot Nothing Then
For Each image As Catalog.ProductImage In product.AdditionalImages
If image.FileName = oldMedImage Then
shouldAdd = False
Exit For
End If
Next
End If
If shouldAdd Then
Dim newImage As New Catalog.ProductImage()
newImage.FileName = oldMedImage
newImage.ProductId = product.Bvin
newImage.Bvin = String.Empty
Catalog.ProductImage.Insert(newImage)
End If
End If
End If
End Function

Public Shared Function GetFullPhysicalFileName(ByVal physicalRoot As String, ByVal file As String) As String
Return Path.Combine(physicalRoot, file)
End Function

Public Shared Function ResizeImage(ByVal oldFile As String, ByVal newSufix As String, ByVal physicalRoot As String, ByVal newWidth As Integer, ByVal newHeight As Integer) As String
If String.IsNullOrEmpty(oldFile) Then
Return Nothing
End If

Dim newImageName As String = GetNewFullFileName(oldFile, newSufix)
If newImageName = oldFile Then
Return Nothing
End If

Dim ext As String = Path.GetExtension(newImageName)
If ext.ToLower() <> ".jpg" Then
newImageName = newImageName.Substring(0, newImageName.Length - ext.Length) + ".jpg"
End If

Dim newImageFileName As String = GetFullPhysicalFileName(physicalRoot, newImageName)
Dim oldImageFileName As String = GetFullPhysicalFileName(physicalRoot, oldFile)

If File.Exists(newImageFileName) Then
Return newImageName
Else
Try
ResizeImage(oldImageFileName, newImageFileName, newWidth, newHeight)
Return newImageName
Catch ex As Exception
EventLog.LogEvent(ex)
Return Nothing
End Try
End If
Return Nothing
End Function

Public Shared Function GetNewFullFileName(ByVal oldFile As String, ByVal newSufix As String) As String
Dim imageName As String = Path.GetFileNameWithoutExtension(oldFile)
If imageName.EndsWith(newSufix) Then
Return imageName
End If
Dim newImageName As String
newImageName = imageName + newSufix + Path.GetExtension(oldFile)
newImageName = Path.Combine(Path.GetDirectoryName(oldFile), newImageName)
Return newImageName
End Function


Public Shared Function ResizeImage(ByVal oldFile As String, ByVal newFile As String, ByVal maxWidth As Integer, ByVal maxHeight As Integer) As Boolean
Dim g As Graphics = Nothing
Try
Dim originalImageInfo As ImageInfo = ImageHelper.GetImageInformation(oldFile)
Dim originalImg As Image = Image.FromFile(oldFile)
Dim originalImageSize As Size = New Size(originalImageInfo.Width, originalImageInfo.Height)

Dim newImageInfo As ImageInfo
newImageInfo = ImageHelper.GetProportionalImageDimensionsForImage(originalImageInfo, maxWidth, maxHeight)

Dim newImageSize As Size = New Size(newImageInfo.Width, newImageInfo.Height)

Dim img As Image = New Bitmap(newImageInfo.Width, newImageInfo.Height)
g = Graphics.FromImage(img)
g.InterpolationMode = InterpolationMode.HighQualityBicubic
g.DrawImage(originalImg, New Rectangle(New Point(0, 0), newImageSize), New Rectangle(New Point(0, 0), originalImageSize), GraphicsUnit.Pixel)
g.Dispose()

Dim ext As String = Path.GetExtension(newFile)
If ext.ToLower() <> ".jpg" Then
newFile = newFile.Substring(0, newFile.Length - ext.Length) + ".jpg"
End If

Dim qualityParam As EncoderParameter = New EncoderParameter(Encoder.Quality, 90)
' Jpeg image codec
Dim jpegCodec As ImageCodecInfo = GetEncoderInfo("image/jpeg")

Dim encoderParams As EncoderParameters = New EncoderParameters(1)
encoderParams.Param().SetValue(qualityParam, 0)

img.Save(newFile, jpegCodec, encoderParams)

Return True
Catch ex As Exception
EventLog.LogEvent(ex)
If g IsNot Nothing Then
g.Dispose()
End If
End Try
Return False
End Function

Private Shared Function GetEncoderInfo(ByVal mimeType As String) As ImageCodecInfo
Dim codecs As ImageCodecInfo() = ImageCodecInfo.GetImageEncoders()

For Each codec As ImageCodecInfo In codecs
If codec.MimeType = mimeType Then
Return codec
End If
Next
Return Nothing
End Function

Fix the imports at the top of the file:
Imports System.IO
Imports System.Web
Imports System.Data
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports Microsoft.VisualBasic
Imports BVSoftware.Bvc5.Core
Imports BVSoftware.Bvc5.Core.Utilities

Now if all is good you should be able to assign a single image to your product in the Medium image. Then click update. The code will automatically create a small and a medium image and assign them and use the original image as an aditional image.

Regards,
Corneliu.
http://www.bestgames.com.au
http://www.bestchess.com.au



BV Product Links, Details and Signatures: Improve your customer experience:

http://www.acorns.com.au/projects/bv/quicklink/

Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

©2024 Develisys. All rights reserved.
  • Toll-free  888-665-8637
  • International  +1 717-220-0012