Support » Fixing WordPress » Auto Align Images

  • Is there any CSS to auto-align all images to the left?

    Or a default setting that I can select to cause all attached images to align that way?

    • This topic was modified 1 year, 5 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • You have posted in the Developing with WordPress forum. Are you asking about this in relation to code, or do you want to change all the images on your site?

    The Classic editor media flow would remember the last used alignment and start with that for the next image. The block editor media flow does not do this.

    The alignment of the images is accomplished by a class on the <img> tag. You can have alignleft, alignright, or aligncenter. If none of these are present, the image is not aligned and will be at the left for left-to-right languages and on the right for right-to-left languages.

    You can change the content of your site with a plugin like Better Search Replace or Search Regex.

    You can change the CSS for the alignment classes, but that would be pretty confusing.

    Moderator bcworkz

    (@bcworkz)

    The media library defaults to the last selected option. You could probably cause it to always be pre-selected as “left” with a bit of JavaScript.

    You could force left alignment with CSS with something like

    figure.alignright, figure.alignnone, figure.aligncenter {
      clear: both;
      float: left;
    }

    With this it wouldn’t matter which alignment option is selected.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Auto Align Images’ is closed to new replies.