Image size as suffix instead of image dimensions

  1. Ipstenu (Mika Epstein)

    Why would there be a filter for every plugin or theme to create it's owned named version of the same image?

    FWIW, there isn't. :) When a theme/plugin does that, it's because they use extra, special, image sizes. (Just explaining for anyone else who wanders into this conversation and scratches their head.)

    The Shortcode could reference the image ID and the desired size.

    Even if you're proposing the shortcode edit the image and create the right size on the fly, this is a bad idea. People upload very very very very very large images. It's far better to have the image resized on upload, where it won't impact the visitor, than to have it done when they hit the page.

    Out of curiosity... Why this push to 'name' images differently?

    Posted: 2 years ago #
  2. José Luís

    @Pat Hawks,

    I understood your idea more like this:

    1. user would click on the "Add media" button;
    2. default Media Library would be shown;
    3. user would select all options; and
    4. instead of inserting a raw image tag, WordPress would insert a shortcode to the image.

    The shortcode (for images) would be something like:
    [media id=XX size=YY]
    Where XX would be the media id (duh!) and size would be one of the sizes shown on step 3.

    When the post was shown, a filter would replace the shortcode with the raw image tag (much like what would be done with and Embed shortcode).

    (hope the verb tenses are correct)

    Posted: 2 years ago #
  3. Pat Hawks


    Yes José Luís, you've got it.

    If we get away from naming images differently...

    The media uploader could insert a shortcode into the post, rather than the img tag it currently inserts, with the image id, desired size, etc.

    The shortcode would just call get_image_tag and translate the shortcode into the standard img tag.

    This way, we don't change the filenames of images, or dynamically resize images each time a user visits the site, or any of these silly things, but the image will change size when the theme changes or when the user changes the sizes in the media settings page.

    This would seem to solve the root of the original problem, without breaking stuff.

    Posted: 2 years ago #
  4. José Luís

    @Pat Hawks, I completely agree with your idea, then.

    @Ipstenu, I don't want to "fix what ain't broken", but I think naming images with their dimensions is a quite strange. If a user (for whatever reason) changed the image dimensions (due to a theme change, for instance), he would be forced to replace all previous references to that image because it changed from my_photo-200x200.jpg to my_photo-75x75.jpg.

    A bit like inserting one's height in his/hers Social Security, when the person grows up a little the social security number doesn't make sense any more.

    If Pat Hawks' idea (Media Library embeding images via shorcodes) would be included in the core, no one would ever have to deal with raw image tags anymore. An inserted/embedded image would be something like:

    [media id=145 size=thumbnail]

    - 145 would be the id of afore mentioned my_photo.jpg image;
    - thumbnail would be one existing registered size, if that size changed, all thumbnails would be changed automatically.

    I think everybody could benefit from this. Could you endorse it, @Ipstenu?

    P.S.: Hope I made myself clear, English is not my first language...

    Posted: 2 years ago #
  5. Ipstenu (Mika Epstein)

    One major problem with it is that we'd have to edit every single theme :/ And I gotta say, not every theme dev is going to be down with that. We would have to make sure for forward and backward compatibility, and it's a lot of work for something that isn't broken, it's just different.

    And that's kind of the crux. In a perfect world, could we have done this better? Sure, but when you get this far into a problem, starting over isn't a great option :/ Wish it was.

    If a user (for whatever reason) changed the image dimensions (due to a theme change, for instance), he would be forced to replace all previous references to that image because it changed from my_photo-200x200.jpg to my_photo-75x75.jpg.

    We actually have a resizer plugin for that. :) Because of how themes work now, they can autodetect the thumbnail, based on your settings, and they know what size it is. And yes, it's a hassle to rebuild the images, but your suggestion wouldn't fix that. You would still have to do that, because a theme pointing to my_photo-thumb.jpg would now be the wrong size.

    With the image sizes in the name, we can quickly tell what images aren't changed, at least.

    the image will change size when the theme changes or when the user changes the sizes in the media settings page.

    A sound idea, but alas impractical. I have a gig of images. If I changed a theme and then my server processed all those images, I'd probably crash it. It would have to be an opt-in process.

    Posted: 2 years ago #
  6. Pat Hawks


    We're not talking about changing image names any more.
    We've moved on.

    Posted: 2 years ago #
  7. José Luís


    As, Pat Hawks says, in the beginning we were talking about changing image names (see my opening post on page 1). But, after a little brainstorming, we moved on.

    Now, we're talking about inserting images on posts via shortcodes, similar to what is done with "embed shortcode". An idea much more advanced and flexible because images would be included by ID, leaving them completely name and location (URL) independent.

    Take a look on my attempt to describe Pat's idea, above.

    I really think this would be a great improvement, but we need someone to endorse this idea before the dev teams.

    Posted: 2 years ago #
  8. Ipstenu (Mika Epstein)

    Let me rephrase.

    What benefit is there in changing the image name from image-100x100.jpg to image-thumbnail.jpg?

    I get you're interested in doing it, but I don't see any benefit other than it'd look "better". We never actually call images by the URL with 100x100 anyway, we use the WP media tool to insert "medium" or "thumb" as we want, and themes are built to extract which image is what.

    Basically I don't see a functionality change :) It doesn't fix a problem, and it doesn't seem to add anything to what we already have. That's why I'm asking why :) I'm sure you see an add on that I don't.

    Shortcodes for images has gone around a few times. We try not to since it affects portability in weird ways, but there could be a case made for it. You'll find a lot of developers are anti-Shortcodes. And if we're not going to go for image renaming (which is still sort of at the heart of the design change you're talking about) then one of you may want to clearly rephrase the pitch :)

    Posted: 2 years ago #
  9. José Luís


    Ok, let's change the approach: a blogger sets his medium size images to 200px wide in media options. He uses TwentyTwelve and, apart from setting featured images, likes to insert medium sized images in most (but not necessarily all) of his posts.

    One day, he decides to change themes, let's say from TwentyTwelve to MyOtherTheme. Unfortunatelly, 200px images are too narrow for this new theme and he decides to batch resize his images to 300px wide. So far, so good.

    Now all of his medium sized images are named IMAGE-200x???.jpg and he needs to change their URL in the image tags to IMAGE-300x???.jpg.

    Problem is: to maintain aspect ratio, he must change the height on all those URL, increasing them by 150%. Not to mention width and height attributes too. If those images were inserted via shortcodes, all these changes (not the resizing!) would be done automatically while rendering the page...

    What do you think?

    @Pat Hawks, is English your first language? Can you help me here?

    Posted: 2 years ago #
  10. Ipstenu (Mika Epstein)

    Aspect ratio is a non-problem in this case, since that isn't how the image size is calculated. It's not going to become image-300px, what actually happens is the theme grabs image.jpg and resizes it via CSS to width or height of 300, based on longest side. So if image.jpg is 600x800 then it would make the width 300, and the height whatever that is, but not rename or resize.

    Now. If you wanna say that we should resize then and there in general, hellz yes! :) Loading the full sized image is a pain in the tush! And in that case, we really should resize.

    But a shortcode is a null factor here, since it doesn't impact anything. The only time you really care about the 'right' size being generated is when it impacts themes, and that's going to be thumbnail size or if the theme defines a special image size for itself. Inside your post, you rarely (if ever) want to change the size of your images. I mean... why do you care if the thumbnails for old posts are 200x200 or 300x300? You designed the content of your post around it already.

    Posted: 2 years ago #

RSS feed for this topic

Reply »

You must log in to post.

  • Rating

    9 Votes
  • Status

    Sorry, not right now