-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Dynamically Media-process images with fixed size in HTML #6986
Comments
I agree that this need to be a feature that you can enable/disable mostly because now responsive design uses images that have width="100%" that stretch with the window size. If we keep the full sized image for keeping image quality on wider screen it makes less files to manage and sometimes as much efficient size wise. |
You can still use 100% width and use this feature. Just set the height/width atts to the maximum size you'll need for any viewport, but upload just the full-res. As mentioned, this is targeting IHTMLFilter implementors. If you are using or thinking about e.g. sliders then these are better implemented with fixed Image profiles. A common usage scenario is:
This is where this feature kicks in and creates a dynamic 120px profile. I agree that this need to be a feature that you can enable/disable mostly because now responsive design uses images that have width="100%" that stretch twith the window size. If we keep the full sized image for keeping image quality on wider screen it makes less files to manage and sometimes as much efficient size wise. You are receiving this because you authored the thread. |
Yeah, but if your image is 120px and you need to display it in 100% width on a QHD screen you will only see big pixels 😄 I understand your request and I think this is a good idea, though it needs to be a feature that works with any Wysiwyg editor out there. So, it must be post-processed if enabled. The only thing I'm worried about is the scope; per image, per editor, per body part, per ... |
Simple: Don't resize to 120px in the editor and you'll get the original size. It will work with any editor, TinyMce included, because it doesn't operate at that level, it uses IHTMLFilter. Important to note it also does not apply to images already the result of a profile. Anyway, all good input. I'll submit the code shortly and you can check it out. Yeah, but if your image is 120px and you need to display it in 100% width on a QHD screen you will only see big pixels 😄 I understand your request and I think this is a good idea, though it needs to be a feature that works with any Wysiwyg editor out there. So, it must be post-processed if enabled. The only thing I'm worried about is the scope; per image, per editor, per body part, per ... You are receiving this because you authored the thread. |
PR created: #6992 |
This seems like a useful feature, but I'm not sure it should be part of the core distribution, so I would like to ask other people's opinion on this as well. /cc @sebastienros @bleroy @pszmyd @DanielStolt @Jetski5822 We also discussed enhancing the media library picker to allow providing additional information, for example selecting one or more profiles associated with view port sizes to render multiple sources. |
Maybe add support for |
+1 for picture and img srcset |
Yes, agreed.
To work with The one thing though, that I find a recurring issue with my users is that working with Orchard is difficult for an average editor, especially uploading and working with images. Further requirements on a user inputting additional info makes me a bit wary that we're adding further end-user complexity. If we're considering dynamically populating e.g. a |
@sfmskywalker I recall we had a discussion about using in It occurs to me that this request could be combined with that one, to solve both problems at once. If we stop embedding pre-resolved media URLs in content and instead embed media item references, those could also contain size/profile information, and we could use all existing logic in the media library picker field to process. |
Good point, I have always argued that the media URL should be embedded relative to /Media as a level of indirection. Though that has it's issues and your idea of using an encoded ID will work around those. In fact, where needed we use a custom implementation of the media module that does exactly that (but relative to /Media). MediaProcessing should also make the
b) allows for domain moves with wildcard 301's to images and image profiles, That would complete the Use Case? My only doubt is that this filter would have one leg in MediaLibrary and another in MediaProcessing. So perhaps the MediaLibrary module should expose an interface for eg. an |
a) Exactly - we are doing roughly the same thing, but in the recipe during the deployment process. Fair point about separating the responsibilities. On the other hand, MediaLibrary already depends on MediaProcessing and knows about it, so perhaps it's OK that MediaLibrary has the knowledge of how to embed a processing profile in the media reference and resolve this to a URL that invokes MediaProcessing to execute it? |
Is the current PR the final answer or do we want to wait for more features like the ones discussed here? |
I would like to include |
* #6986 Created feature Media Processing Html Filter * Fixing HtmlAgilityPack and upgrading FW and package version to match Orchard.Specs * Adapting MediaProcessingHtmlFilter to IHtmlFilter breaking change * Fixing that Orchard.MediaProcessingHtmlFilter should depend on Orchard.MediaProcessing * Code styling * Using regexes instead of HtmlAgilityPack, thanks GHCP * Updating comments and code styling * Code styling * Reworking ProcessContent to use StringBuilder instead of replaces * Fixing that GetAttributeRegex should find attributes with empty value * Code styling * Fixing that detecting the extension works regardless of casing but it still works with Azure Blob Storage (which is case-sensitive) too * Optimizing image tag regex * Caching attribute regexes * Caching attribute values of img tags * Simplifying attribute value cache --------- Co-authored-by: Arjan Noordende <arjan@zumey.com>
Images inserted in HTML through, e.g. any content with a Body can be resized through the editor. However, the full size image will still be served whereas it would be more efficient, especially on mobile clients, to serve a pre-sized image.
It is quite straightforward to dynamically cut these images to size using the MediaProcessing module in combination with IHtmlFilter. Of course, it needs to be a feature that can be turned on or off as desired.
The one requirement is that the height/width attributes are provided, which will be when resizing through the TinyMce editor. This also provides an excellent trick when you particularly don't want an image to be resized: omit the height or width.
As I've had this code live for a few years already, the PR is to follow shortly.
The text was updated successfully, but these errors were encountered: