Attachments, images and media

On this page the terms attachment, image and media are used interchangably. Strictly speaking, only media attached to a post can be called an attachment.

Post attachments are automatically broadcasted to the child posts upon publishing / updating. Other media may also be copied at the same time.

  • Featured images
  • Media references in shortcodes in the post
  • Media references in custom fields using various add-ons

How media is handled during a Broadcast

Preparations on the parent blog

When the publish button is pressed, Broadcast will:

  1. Take a note of all media IDs directly attached to the post.
  2. Note the featured image ID, if any.
  3. Examine all gallery shortcodes and all media IDs found within are noted.
  4. Various add-ons will try to find media IDs in various places, for example:

Preparations on the child blog

If the child post already exists, Broadcast will delete all attached media. This is to ensure that all media is kept updated on all child blogs. The deletion can be prevented by using the Protect Child Properties or Update Attachments add-ons.

After the attachments are cleared, Broadcast will try to copy all media.

Copying the media

One after one, all attachments are attempted to be copied to the child blog.

Broadcast will first check to see if a media file with the exact same slug already exists on the blog. If so, the admin setting existing attachments dictates the action to take:

  1. The existing media can be used.
  2. The existing media can be deleted and recopied (overwrite).
  3. The name of the media can be modified slightly when being copied (randomize)

The default is to use the existing media ID.
Using option #2 can result in broken links if other posts reference the same media.
Option #3 will generate very many duplicates.

Each copied media will result in the metadata and thumbnails being regenerated. This usually takes a few seconds per image. To save time and help prevent PHP timeouts, the Duplicate Attachments add-on will directly copy the media without regenerating anything.

Modifying the media IDs

In the case of gallery shortcodes, the contained media IDs are modified to point to the equivalent media on the child post. If you use other shortcodes that contain media IDs, you should have a look at the Shortcode Attachments add-on.

Featured images

A featured image, which WordPress internalls calls a thumbnail, will automatically be copied whether attached to the post or not.

Comments

  1. Is posible to switch off this feature? For example i do not need to copy files if they are reachable on the paretn site… thanks!

    1. Not currently, no. Are the attachments part of a gallery or a featured image or something?

  2. Hi,
    I am using SiteOrigin Page Builder and when I broadcast pages that are managed with the builder, my images disappear. What’s very strange is that the HTML of page actually changes. So instead of:

    I get this, on my child site:

    As you can see, the entire ‘src’ attribute disappeared from the ‘img’ tag, therefore nothing is displayed on my child page.
    How can I fix this and broadcast images that are within page builder?
    Thanks!

    1. It looks like your HTML got stripped out. You should e-mail me your code and a debug dump and we can then see what we can see.

  3. Is it still not possible to stop the images from being copied and simply have the link to the parent site? We have a client with a very large site with 15+ child sites so this is becoming a huge issues for our client’s hosting.

    1. Still not possible due to technical limitations in WordPress: all media on each blogs needs its own ID.

      You can try a CDN, that does not store images on disk, such as the WP Offload S3 Lite plugin, which others have successfully tested with Broadcast.

    1. You mean, instead of physically copying the files, they are symlinked and then inserted into the media library?

  4. Hello,

    we’re setting up a Multi-Site on WordPress and we figured out a massive problem with post/featured images.

    When we set up a featured image, the main site will show it and all the sub-pages will ignore it on the blog main-page.

    The image itself is copied under the “media section”, but isn’t linked with the child post item.

    Is there any setting which needs to be enabled?

    A lot of posts were already written – sometimes the featured image is linked and now no new post will do that.

    Hopefully you can help us!

    Best regards,
    Stefan

    1. What do you mean by “sub-pages will ignore it on the blog main-page”?

  5. we publish the posts on the main-site and broadcast it to the other pages – and the child-pages won’t show the image on the site. neither on the blog overview nor on the single post page.

    1. Could you e-mail me a debug dump of the post in question? I’d like to see what broadcast is doing with the images.

  6. Ok, please write me a mail with a short description how I could do this (you see my mail-address or?)

    Then I’ll forward the dump to you when you’ve provided me a short tutorial :)

    1. For others wondering, the problem was that the “custom fields” Broadcast checkbox was not checked during broadcasting. Therefore BC ignored the featured image, since it is stored in a custom field.

  7. Hi. I use broadcast plugin to share content on big (100+) multisites.
    I don’t need to replicate images on every site, and I’m thinking to couple broadcast to a “shared media library” plugin like this https://it.wordpress.org/plugins/network-shared-media/ (not this, but something similar, there are a lot).
    Have you an extension to handle something like this?
    Have someone experience on something similar? I’m a developer, it’s not a problem to write some code to make the mix.

    1. There is no elegant solution.

      WordPress handles attachments by ID, and since each blog has different IDs for the same images, there will have to be copies of the image on each blog.

      The usual solutions are either to get bigger web hosting (there are places that offer 2TB of warm storage for 20e a month), use a CDN offloading plugin (S3 Lite seems to work well) or referring to images statically instead of dynamically using image IDs.

      I just recently helped someone cut down on 80% of their site size by putting all broadcasted images onto a shared directory, and the images were then refereced statically.

    2. Hi Edward

      Did you have any more information about how you achieved your last comment regarding putting all images into a shared directory? I am keen to do something similar.

    3. The person went through their theme and posts, replacing all [gallery] shortcodes and image references using IDs, to static references using the IMG HTML tag. Everything was changed to a relative / complete URL to the image.

      It required a lot of work to clean up the theme to not use featured images anymore and to ensure that there were no more IDs used anywhere, but it was worth it for the person, since space was expensive.

      For me, I pay 10€ a month for 2TB of image storage, so it’s easiest for me to just use the default WordPress way of handling images.

      If this is still unclear, e-mail me and I’ll try to explain further.

  8. I used broadcast to copy a post to a subsite. The post had a featured image. All images and documents reference in the parent post were successfully copied into the media library of the subsite. Only the featured image reference was changed to pull the image from the subsite’s image library. All the rest of the references within the post pull images and documents from the parent page. Shouldn’t these also pull images and documents from the subsite’s library? I ran a debug when I did it. Also, I had all the checkboxes checked when I pushed the post to the subsite (Link this post to its children, custom fields, taxonomies). Should I send you the link to the debug page?

    1. By default, featured images and images in gallery shortcodes are automatically detected and copied over. Other images, in normal image links or embedded in shortcodes or page builder data require special handling. Exactly what kind of handling is necessary I can say more precisely in your case if you could e-mail me a Broadcast debug text of the post in question.

    2. Do I need an email address for you or should I post it here?? I have a link to the debug output. Is that OK to send or should I copy that page and send as text?

    3. My e-mail address is visible under the “contact” page in the menu. You can either send me the link to the debug file or as a text. Whichever is easier for you.

  9. Using Offload media to S3 bucket, when you send to many no images are found as the files exist in s3 and not in the local directory.

    Is there a function or something I can update to look at s3 replacing the lookup for the local path?

    1. There are two parts to this answer:

      1. If you wish to modify attachment information, hook into the threewp_broadcast_broadcasting_started action, and the $action->broadcasting_data->attachment_data array has the information from all of the found attachments, including URLs and file paths.

      2. The CDN Workaround has a “copy remote files” option that will download the images to each child blog and use internal WordPress functions to insert the media during broadcasting.

      I hope this answers your question somewhat.

Leave a Reply to Stefan T. Cancel reply

Your email address will not be published. Required fields are marked *