JENS MALMGREN I create, that is my hobby.

Porting my blog for the second time, render posts part 10

This is post #32 of my series about how I port this blog from Blogengine.NET 2.5 ASPX on a Windows Server 2003 to a Linux Ubuntu server, Apache2, MySQL and PHP. A so called LAMP. The introduction to this project can be found in this blog post https://www.malmgren.nl/post/Porting-my-blog-for-the-second-time-Project-can-start.aspx.

Programming and especially finding bugs many times is detective work. Here is an example of that. I noticed in my new blog that the images in a couple of posts was displayed with incorrect width and height. It looked like this:

I looked for the problem with the layout but I could not find any problem. When comparing with the old blog it looked like this:

So the new blog displays the entire image and the old blog just a part of it. Then I tried to find out how the old blog was able to display only a portion of the image and what kind of tricks with styles could do that? It was awesome. It was magic. But it was no magic, it was an illusion.

The truth was that the image source and the anchor link had been mixed up and was being used for both. In the old blog it was two different images and the image being displayed only displayed a part of the entire image.

So now I knew the cause. Where is this handled in my perl import program? Here is the original line of code that should handle the transformation of the filename.

if ($strFileName =~ s/(.*?\/)(s[0-9]+)(\/)([a-z0-9]+)(\.[a-z]{3,4})$/$4_$2$5/i)

Can you see it? The image filename contains underscores as well but this conversion cannot be used for such image filenames. So to fix this problem the transform line need to also accept underscore characters. Like this:

if ($strFileName =~ s/(.*?\/)(s[0-9]+)(\/)([a-z0-9_]+)(\.[a-z]{3,4})$/$4_$2$5/i)

And it worked!

Nice. I noticed that one post had missing sidebars? But that is for the next time.

I was born 1967 in Stockholm, Sweden. I grew up in the small village Vågdalen in north Sweden. 1989 I moved to Umeå to study Computer Science at University of Umeå. 1995 I moved to the Netherlands where I live in Almere not far from Amsterdam.

Here on this site I let you see my creations.

I create, that is my hobby.