Index: imgalleryplugin.cpp
===================================================================
--- imgalleryplugin.cpp	(revision 729969)
+++ imgalleryplugin.cpp	(working copy)
@@ -188,6 +188,7 @@ void KImGalleryPlugin::createBody(QTextS
     int imgIndex;
     QFileInfo imginfo;
     QPixmap  imgProp;
+    QString imgNameFormat;
     for (imgIndex = 0; !m_cancelled && (imgIndex < numOfImages);) {
         stream << "<tr>" << endl;
 
@@ -200,9 +201,8 @@ void KImGalleryPlugin::createBody(QTextS
                 stream << "<td align='center'>\n<a href=\"" << imgName << "\">";
             }
 
-
-            if (createThumb(imgName, sourceDirName, imgGalleryDir, imageFormat)) {
-                const QString imgPath("thumbs/" + imgName + extension(imageFormat));
+            if (createThumb(imgName, imgNameFormat, sourceDirName, imgGalleryDir, imageFormat)) {
+                const QString imgPath("thumbs/" + imgNameFormat);
                 stream << "<img src=\"" << imgPath << "\" width=\"" << m_imgWidth << "\" ";
                 stream << "height=\"" << m_imgHeight << "\" alt=\"" << imgPath << "\"/>";
                 m_progressDlg->setLabelText( i18n("Created thumbnail for: \n%1").arg(imgName) );
@@ -420,9 +420,15 @@ void KImGalleryPlugin::loadCommentFile()
     }
 }
 
-bool KImGalleryPlugin::createThumb( const QString& imgName, const QString& sourceDirName,
-                                    const QString& imgGalleryDir, const QString& imageFormat)
+bool KImGalleryPlugin::createThumb( const QString& imgName, QString& imgNameFormat, const QString& sourceDirName, const QString& imgGalleryDir, const QString& imageFormat)
 {
+
+    int imgDot = 0;
+    QString thumbName = imgName;
+	while ( (imgDot = thumbName.find( '.', imgDot )) >= 0 ) {
+	    thumbName = thumbName.replace( (uint) imgDot, 1, '_' );
+        }
+
     QImage img;
     const QString pixPath = sourceDirName + QString::fromLatin1("/") + imgName;
 
@@ -434,7 +440,7 @@ bool KImGalleryPlugin::createThumb( cons
         KIO::NetAccess::copy(srcURL, destURL, static_cast<KParts::Part *>(parent())->widget());
     }
 
-    const QString imgNameFormat = imgName + extension(imageFormat);
+    imgNameFormat = thumbName + extension(imageFormat);
     const QString thumbDir = imgGalleryDir + QString::fromLatin1("/thumbs/");
     int extent = m_configDlg->getThumbnailSize();
 
Index: imgalleryplugin.h
===================================================================
--- imgalleryplugin.h	(revision 729969)
+++ imgalleryplugin.h	(working copy)
@@ -68,7 +68,7 @@ class KImGalleryPlugin : public KParts::
   void createCSSSection(QTextStream& stream);
   void createBody(QTextStream& stream, const QString& sourceDirName, const QStringList& subDirList, const QDir& imageDir, const KURL& url, const QString& imageFormat);
 
-  bool createThumb( const QString& imgName, const QString& sourceDirName, const QString& imgGalleryDir, const QString& imageFormat);
+  bool createThumb( const QString& imgName, QString& imgNameFormat, const QString& sourceDirName, const QString& imgGalleryDir, const QString& imageFormat);
 
   bool createHtml( const KURL& url, const QString& sourceDirName, int recursionLevel, const QString& imageFormat);
   void deleteCancelledGallery( const KURL& url, const QString& sourceDirName, int recursionLevel, const QString& imageFormat);

