Search

There seem to be two approaches to images in Symphony: Either you create a Image field (of Upload type) in the section that needs images. Or you create a separate Image section which have a link to the entry section.

The upside of the first is that image upload is made inline with creating a new entry. The downside is that the number of images a entry can have is limited to the number of upload fields.

That limitation is not there when going the other route. But on the other hand, image upload and entry creation is no longer as streamlined.

My question: Is there a third way I haven't tought about yet?

One limitation with the second approach is that each image can only be associated with one entry. What about creating a third section, that just links between one entry and one image? That way an already uploaded image can be reused over and over again.

You've covered the main ways right there. I was about to mention the link-section idea but you beat me to it! This way you may be able to achieve a true many-to-many relationship with section links. So to recap, you can:

Use Upload fields

Add as many upload fields to your Section as you think you may need. For sections where you know every entry will always have one or two images this is fine, but for blog posts you may want n number of images/files, so this isn't always ideal.

Use an "Images" section

The Images section can comprise an Upload field and perhaps a Text field as a caption. Plus a section link back to your content entry (blog post, article, etc.). This way allows you to add as many images to a post as you like. However the drawbacks are that:

  • the post needs to be created before you can add images
  • from the edit entry page you can't get to the section easily
  • not intuitive for less technical users to understand
  • images cannot be shared between multiple posts

Use an images section with an addition "link" section

As above, but add a another section between Images and Posts which should allow a many-to-many relationship. This solves the problem of sharing images between posts, but is still tricky to set up and use (not to mention query with a DS?).

Additionally:

Upload via FTP and insert using TinyMCE

Install the TinyMCE text formatter and your textarea can be transformed into a rich-text editor. Not sure whether it is On by default, but there is an option to enable an icon to insert images to the HTML. This allows you to type in the image URL and provide alt/title values.

Use the Inline Section field

It's still a rough proof of concept, but my Inline Section field can be adapted for this use. Originally it began as a generic way to push any section inline. I struggled to think of applications for the idea, and the only one I could think of was images. Take a look at the screenshot and you'll see what I mean.

You could potentially add a JS click event to each entry inside the inline section to insert the image URL (as Markdown, HTML, etc) into a textarea. Or simply another DS to pull the images in (since it is just a section link).

The JS and CSS can certainly be improved, but it's a novel idea.

File Manager extension

The old file manager doesn't work properly with S2.0, but I am aware of plans to revamp the extension and bring it in line with what we need. I envisage the File Manager extension solving this problem in either one of two ways. Both involve the extension also adding a new field type, "File Browser". When added to a section, it displays one of two things. Either:

  • An inline "Browse" panel that allows a user to navigate a stripped down File Manager view and tag or tick checkboxes beside which files in the list they want to include with this section. Or indeed upload new files. Or:

  • Automatically create a new directory based on the section and ID of the entry, into which files can be dropped. For example, imagine adding files for a blog post (a Blog Posts section). On the backend, the extension would create a folder using the section handle and entry ID:

    /workspace/uploads/blog-posts/123/

The File Browser field provides a list of files already in that location (plus the ability to delete them) and an upload field to add new ones. In the page XML this field returns an XML nodeset of all files and their meta properties (as an Upload field does). The benefit of this method is that all files are neatly siloed into directories that are easy to retrieve in the future.

Any other thoughts?

Having the pictures outside the entries/articles/whatever brings another problem as well: When the number of images and entries increase, the lists with available items will be long in the link section (or image section depending on approach choosen).

On the other hand, keeping images within each post is also limiting.

This takes some time before a choice can be made, I think.

I'm trying to implement the solution with the link bridge. Three sections are in play:

  • Blog entries
  • Images
  • Image bridge (which has two fields: Blog entry and Image, both Select Box Links to the two sections above.)

When creating the XML, the DS getting the actual blog entry has System ID as Parameter Output: $ds-blog.

Second DS is based on Image bridge: Here I use $ds-blog to filter out images linked to that specific blog entry. Up to here, things work and I get this in my XML:

<blog-image-list>
        <section id="9" handle="image-bridge-blog">Image bridge blog</section>
        <entry id="268">
            <image>
                    <item handle="night" id="267">Night</item>
            </image>
        </entry>
    </blog-image-list>

This DS also has System ID as parameter output: $ds-blog-image-list. The final DS, working on the Image Section is filtered by that parameter. But the result is empty, even though the parameter is set. "No records found" is the message in the XML.

What mistake am I doing?

I found it. The $ds-blog-image-list parameter isn't the System ID of the actual images. Of course not. It's the System ID of the bridge entry in the Image bridge section. In the example above, the value of the parameter is 268, not 267 which is the value I really need to filter by in the last DS.

But I'm still stuck. That section only has two Section Link Boxes as fields. And these are not available to choose as Parameter Output.

I think this is a bug of the Select Link Box field. Having the ID available as an output param (of the original Section Link field) wasn't possible until quite recently; Alistair made a quick change and enabled it. The same change should be possible to this Select Link Box field. We need to pester Alistair or Rowan — it's quite a limiting factor!

I'm pretty sure this is the fix you are after:

http://bugs.symphony21.com/comments.php?DiscussionID=348&page=1#Item_0

Unfortunately not. That function is already present in the code I have.

That line will enable the field to be used as a "group by" field in the DS output. Try adding this:

    function allowDatasourceParamOutput(){
        return true;
    }

Good. Got it working.

Now, next issue is the get the entry list of the Image Bridge section to contain some useful information. If I choose to display columns for both the Section Link Boxes, the one going to the blog section and the one to the image section, only the link to the image section is really shown. And if I choose to include non of them, all I get is a list of System IDs for each bridge entry.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details