Anomaly attaching image files

Created on 7 June 2015, over 9 years ago
Updated 22 December 2024, 15 days ago

If you set the variable to convert embedded images into links (variable mimemail_linkonly), then you can't attach image files - any image files added as attachments silently disappear.

I have solved the problem for myself by adding

if ($disposition == 'attachment') $linkonly = 0;

after line 167 of mimemail.inc, so that the start of _mimemail_file now reads:

function _mimemail_file($url = NULL, $content = NULL, $name = '', $type = '', $disposition = 'inline') {
  static $files = array();
  static $ids = array();

  if ($url) {
    $image = preg_match('!\.(png|gif|jpg|jpeg)$!i', $url);
    $linkonly = variable_get('mimemail_linkonly', 0);
    if ($disposition == 'attachment') $linkonly = 0;
    // The file exists on the server as-is. Allows for non-web-accessible files.

I am not aware of the wider ramifications of that change.

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡³πŸ‡ΏNew Zealand Cadencia

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024