Forum

Thread tagged as: Question, Problem, Forms

Generated code differs between live and development environment

Hiya,

I've just been setting up a site for a client and have noticed an oddity after putting the site live.

When an image is added through the generated HTML appears to differ between the live and development environments.

The live version is adding in height and width attributes to the img tag, whereas in development it wasn't. This has resulted in a few distorted images due to widths being set in CSS and the height being set in the HTML. I've managed a CSS hack in the meantime, but it would be good to know what's the cause.

On a side note, but could be related. The textile code for the images appears to differ between the 2 environments too?

Thanks in advance!

Alan

Alan Kirk

Alan Kirk 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do they have different configuration settings? e.g. is one using PERCH_HTML5 and the other not?

Hi Drew,

Thanks for your reply. No, both have the same settings. It was after a direct upload from one environment to the other, which has thrown me. The only difference I can see is that live is using ImageMagick, where as locally it has both GD and ImageMagick set up.

Is the generated code influenced by which library is being used?

Thanks,

Alan

Drew McLellan

Drew McLellan 2638 points
Perch Support

That's hard to say without context. How are the image tags being generated? Can you show us your template?

Sorry Drew,

In Perch, the region is set up as a Text Block, so the image is being uploaded and placed using the Textarea Editor.

The resulting image code in Perch in my dev environments (local [OS X] & Staging [Debian]) is:

![Chris sat at his desk](/~alankirk/olivedigital-site/htdocs/perch/resources/photochris-w640h480.jpg)

resulting in the following HTML

<img alt="Chris sat at his desk" src="/~alankirk/olivedigital-site/htdocs/perch/resources/photochris-w640h480.jpg">

But on the live site, Perch has the image as

!/perch/resources/photochris-w640h480.jpg(Chris sat at his desk)!

with the HTML as

<img alt="Chris sat at his desk" height="244" src="/perch/resources/photochris-w640h480.jpg" title="Chris sat at his desk" width="366">

which has the height and width showing inline

All the site versions are using the following code in the Text Block Perch template:

<perch:content id="text" type="textarea" label="Text" textile="true" editor="markitup" imagewidth="640" imageheight="480" />

Let me know if there's anything else that might shed light on what's going on.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I think it's your tilde path.

The image processing here is down by Textile, which is an open source library. It parses for the images and then tries to find the file based on the path. Tilde path are weird and don't behave like normal paths - so I think it's failing to find the images and so can't get the dimensions from the file.

Which way do you want the output? If you don't want the image dimensions, you can switch that off with the PERCH_RWD config option.

https://docs.grabaperch.com/docs/installing-perch/configuration/markup/

Thanks Drew,

(Sorry for the late acknowledgment!)

Ah, I see. It was a quick set up on my Mac, hence the tilde path. I'm not really wanting the image dimensions, so I'll check out that link and turn them off.

Thanks again!