Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

groupserver/gs.group.messages.image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gs.group.messages.image

The images displayed in a GroupServer group

Author: Michael JasonSmith
Contact: Michael JasonSmith <[email protected]>
Date: 2015-10-15
Organization: GroupServer.org
Copyright: This document is licensed under a Creative Commons Attribution-Share Alike 4.0 International License by OnlineGroups.Net.

Introduction

This is the code for displaying images that have been posted to a group. It provides two major components: a content provider for displaying an image, and the image page.

Content Provider

The content provider groupserver.GroupImage displays an image that has been posted to a group. It takes four arguments:

fileId:The file identifier (required).
alt:The alt-text (optional, default is blank).
width:The width of the image, in pixels (option, default is 50).
height:The height of the image, in pixels (option, default is 70).

For example, displaying an image with a maximum size of 100 pixels high and 100 wide:

<span tal:define="fileId view/imageId; width 100; height 100; alt
                  string:The posted image ${view/filename};"
                  tal:replace="structure
                  provider:groupserver.GroupImage">An image</span>

The image is acquired using the virtual file-archive [1]. The image is then re-sized by gs.image [2] in such a way that the original aspect ratio is kept. The content provider will then produce an <img> element. Based on the result of the re-sizing the src attribute will link to one of three things:

  1. The original file ({group}/files/f/{fileId}), if no resizing was needed.
  2. The re-sized file ({originalFileLink}/resize/{width}/{height}) if resizing is needed and the image is bigger than 1K.
  3. A data-URI if the image is smaller than 1K.

The square image content provider also re-sizes, but ensures the image is square.

Square Image

The square image content provider, groupserver.SquareGroupImage, always produces square images, rather than possibly rectangular images. It takes three arguments:

fileId:The file identifier (required).
alt:The alt-text (optional, default is blank).
size:The width and height of the image, in pixels (option, default is 50).

The image is re-sized (or not) by gs.image [2], and the same rules for linking to the image apply:

  • No change: {group}/files/f/{fileId}
  • Resized: {originalFileLink}/square/{size}
  • Tiny: a data-URI.

Image Page

The Image page, image in the Messages context, exists because people often post very large images to groups. The Image page re-sizes the image to something that is easier to view on the Web, and share using the Sharebox JavaScript.

The actual image page is gsimage, in the Messages context. The image page performs the traversal of the URL to either parse the file ID out, or display one of the error pages

Sharebox JavaScript

The Image page makes use of the resource gs-group-messages-image-20130305.js to provide the code for the Share button [3].

Error pages

There are two error pages, specific to the Image page.

400 (Bad request):
The URL was missing the file identifier, so the gsimage400 page is shown.
410 (Gone):
The identifier for the image could be found, but the associated post is hidden, so the image_hidden.html page is shown.

If the file could not be found then the standard 404 page is shown.

Resources

[1]See Products.XWFFileLibrary2 <https://github.com/groupserver/Products.XWFFileLibrary2>
[2](1, 2) See gs.image <https://github.com/groupserver/gs.group.messages.image>
[3]See gs.content.js.sharebox <https://github.com/groupserver/gs.content.js.sharebox>

About

The Image page (image in a post)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •