MG 1.1 Description formatting: line breaks and links


Active member
Importing from photopost where descriptions maintained new lines and auto linked URLS within descriptions.

In XFMG, now any URLS in descriptions are not linked and any line breaks are removed.

Is there a way to autolink http:// links and maintain line breaks in descriptions?

Chris D

XenForo developer
Staff member
There isn't. As you will see throughout XF descriptions are plain text and only suitable for shorter snippets of information.

It is recommended that you use a custom gallery field for this of the "rich text" type and position that somewhere prominent.

It will allow all the formatting required, auto link URLs and be a more appropriate size and position.


Active member
Always a little complication (although other than this detail, the import went quite smoothly)

After completing the photopost import of ~20,000 photos, under XFMG I have one Gallery Field named "Caption". In XFMG admin, it says description "Enter a caption for this media. You may use BB Code." and under the Options for Text Fields tab it is "Rich text box"
I did not create this custom field, so I was thinking it was the field where the photopost descriptions would be imported. Now that I look at the mysql database, I see the photopost descriptions were all imported into the media_description column which shows in the template as {$media.media_description}

So now, big questions, if I want to (or can) maintain the basic photopost description formatting, with the goal of only having line breaks and urls linked/clickable.

Do I manually try and copy the plain text description column imported from photopost into the caption field in phpmyadmin? Looking with phpmyadmin, links are "linked" with BBCode before being saved in the mysql field by XFMG, so there are no [ url ] bbcodes in the media_description field. It appears photopost handled basic url linking when it rendered the page not saving [ url ] bbcode in the database. So if I wanted to maintain the links in descriptions, I would not only need to manually copy the table to the new rich text field, but also run a query to add the opening and closing url bbcode. The replace for the http:// with [ url ]http:// would be easy, and it probably would be doable to add a /url bb code before the first space following any sequence of characters following http although I might need a little help with the regex for that one.

Thinking further, if I did this, would I then empty the description column so as not to have an exact duplicate of description and caption? (or just remove the {$media.media_description} from the xengallery_media_view so I didn't have a duplication on the page as I wouldn't want a plaintext right above a rich text version of the same text. Do I want to have both a description and caption entry blank every time someone uploads a photo going forward? This seems complicated. Also not sure I want the full rich text editor as I do like the clean look of the XFMG page with a clean description under the photo and the simplicity of entering only one description for a photo, but I hate to remove the basic line break and links that have been part of the photopost descriptions for years now.

How difficult would it be to add the photopost-behavior very basic <br> and <a href= formatting when rendering the XFMG xengallery_media_view template. (line breaks are retained in the sql media_description column)

A major concern is that in photopost, links were allowed in the description as part of the photo credit, if you will. Maybe to make up for this if it cannot be rendered in XFMG easily as clickable, I can add the user's Home Page field under the media_description on the xengallery_media_view template. for any user who has a home page set in their profile.

Always something...​
Last edited: