Running can improve your cardiovascular outlook without making you immune to cardiovascular disease. Here’s how to make sense of the research on endurance athletes and coronary plaque.
Published: Oct 30, 2026 8:55 am
Most runners reasonably expect that all those miles do something good for their hearts.
Our resting heart rates fall. Paces that once felt difficult become comfortable. We develop the capacity to move more oxygen, sustain more work, and recover faster.
Then a study comes along showing that lifelong endurance athletes have more plaque in their coronary arteries than people who exercise much less.
That’s a difficult finding to reconcile with everything we know about the benefits of running. I keep returning to this topic, partly because the physiology is fascinating and partly because I’m a lifelong endurance athlete with no plans to stop.
The question is worth taking seriously: How can endurance exercise improve cardiovascular health while being associated with more coronary atherosclerosis?
After following this research for years, I think the most useful answer begins with separating things we often treat as interchangeable: how well the heart performs, what its arteries look like, and the likelihood of having a cardiovascular event.
They’re related. But each tells us something different.
A Strong Heart Can Still Have Plaque
Endurance training changes the heart’s structure and function. The term athlete’s heart describes adaptations that help it accommodate and pump the large volumes of blood required during exercise.
For example, a recent study comparing endurance athletes with controls found that athletes maintained larger stroke volumes—the amount of blood pumped per beat—even as rising heart rates shortened the time available for filling. That helps explain their greater cardiac output during exercise. These are useful adaptations for endurance performance.1Spencer, L. W., Flannery, M. D., Janssens, K., Bekhuis, Y., Wright, L., Howden, E. J., Van Puyvelde, T., Prior, D. L., Mitchell, A. M., Rowe, S. J., Foulkes, S. J., & La Gerche, A. (2026). A race against time: Timing constraints of cardiac filling and athletic performance. American Journal of Physiology-Heart and Circulatory Physiology, 330(5), H1423–H1432. https://doi.org/10.1152/ajpheart.00896.2025
Coronary atherosclerosis affects the arteries that supply the heart muscle. Plaque develops within their walls and can contain varying amounts of lipid, fibrous tissue, and calcium.
A coronary artery calcium scan measures the calcified component. The result, the CAC score, indicates atherosclerotic burden and future cardiovascular risk. A different examination, coronary CT angiography, uses contrast to show additional features, including noncalcified plaque and narrowing of the arteries.2Aengevaeren, V. L., Mosterd, A., Bakker, E. A., Braber, T. L., Nathoe, H. M., Sharma, S., Thompson, P. D., Velthuis, B. K., & Eijsvogels, T. M. H. (2023). Exercise volume versus intensity and the progression of coronary atherosclerosis in middle-aged and older athletes: Findings from the MARC-2 study. Circulation, 147(13), 993–1003. https://doi.org/10.1161/circulationaha.122.061173
This distinction matters because a heart can be exceptionally good at supporting a marathon while its coronary arteries still contain plaque.
Your ability to run well tells you something valuable about your physiology. It doesn’t tell you everything.
Why “Stable Plaque” Isn’t the Whole Story
One influential finding came from the original MARC study, which examined 284 male recreational and competitive athletes, averaging 55 years old.
Researchers used CT scans and questionnaires about lifelong exercise habits. Among the highest-volume exercisers, 68% had detectable coronary calcium, compared with 43% in the lowest-volume group. Coronary plaque was present in 77% versus 56%, respectively.
But there was a potentially reassuring detail: among athletes with plaque, the highest-volume group more often had exclusively calcified plaque and less often had mixed plaque.3Aengevaeren, V. L., Mosterd, A., Braber, T. L., Prakken, N. H. J., Doevendans, P. A., Grobbee, D. E., Thompson, P. D., Eijsvogels, T. M. H., & Velthuis, B. K. (2017). Relationship between lifelong exercise volume and coronary atherosclerosis in athletes. Circulation, 136(2), 138–148. https://doi.org/10.1161/circulationaha.117.027834
That helped establish an appealing explanation. Perhaps athletes had more plaque, but a greater proportion was relatively stable and less likely to rupture.
The problem was how easily “potentially more stable” became “nothing to worry about.”
The 2023 Master@Heart study complicated that interpretation. It compared 191 lifelong endurance athletes, 191 athletes who began after age 30, and 176 healthy nonathletes. All were men, averaging about 56 years old. The athlete groups trained roughly 10–11 hours weekly, versus about one hour among controls.4De Bosscher, R., Dausin, C., Claus, P., Bogaert, J., Dymarkowski, S., Goetschalckx, K., Ghekiere, O., Van De Heyning, C. M., Van Herck, P., Paelinck, B., Addouli, H. El, La Gerche, A., Herbots, L., Willems, R., Heidbuchel, H., & Claessen, G. (2023). Lifelong endurance exercise and its relation with coronary atherosclerosis. European Heart Journal, 44(26), 2388–2399. https://doi.org/10.1093/eurheartj/ehad152
Using coronary CT angiography, researchers found at least one plaque in:
- 63.4% of lifelong athletes
- 57.1% of later-starting athletes
- 50.0% of controls
After adjustment for cardiovascular risk factors, lifelong athletes had higher odds of calcified, noncalcified, and mixed plaque than controls. Their plaque composition wasn’t uniquely favorable.
There was nuance: overall plaque burden remained relatively low, and plaques meeting the study’s definition of “vulnerable” were uncommon. The comparison was also cross-sectional, so it couldn’t establish that training caused the differences—or that athletes would subsequently have more heart attacks.
The participants were White men, predominantly cyclists, and controls were unusually healthy. That limits how confidently we can apply the findings to women, other populations, or every recreational runner.
My interpretation is that we should retire the blanket reassurance that athletes simply have harmless plaque. The evidence is more complicated than that.
Mileage, Intensity, And What the Data Can’t Tell Us
The next question is whether continuing to train predicts how plaque changes over time.
MARC-2 reassessed 289 men from the original cohort after an average of 6.3 years. Detectable coronary calcium increased from 52% to 71%, and plaque prevalence rose from 64% to 83%.
Exercise volume during follow-up wasn’t associated with progression. The proportion of exercise classified as vigorous was associated with less calcium progression, while very vigorous exercise was associated with more.5Aengevaeren, V. L., Mosterd, A., Bakker, E. A., Braber, T. L., Nathoe, H. M., Sharma, S., Thompson, P. D., Velthuis, B. K., & Eijsvogels, T. M. H. (2023). Exercise volume versus intensity and the progression of coronary atherosclerosis in middle-aged and older athletes: Findings from the MARC-2 study. Circulation, 147(13), 993–1003. https://doi.org/10.1161/circulationaha.122.061173
Before translating that into “easy miles are safe, intervals are dangerous,” we need to understand the categories.
Intensity was estimated using metabolic equivalents, or METs—multiples of resting energy expenditure assigned to reported activities. Very vigorous meant at least nine METs. Many running activities fell into that category.
These weren’t individually measured heart-rate zones, lactate thresholds, or percentages of VO₂ max. The authors also acknowledged that they couldn’t cleanly separate exercise intensity from sport type.6Aengevaeren, VL, Mosterd, A., Ea, B., Braber, TL, Nathoe, HM, Sharma, S., Thompson, PD, Velthuis, BK, & Eijsvogels, TMH. (2023, March 28). Exercise volume versus intensity and the progression of coronary atherosclerosis in middle-aged and older athletes: Findings from the MARC-2 study. – SORA. Sgul.Ac.Uk. https://openaccess.sgul.ac.uk/id/eprint/115139/
For a trained runner, an activity with a high absolute energy cost can still feel relatively comfortable. The same pace might be an easy run for one person and a demanding workout for another.
That makes the finding interesting scientifically but difficult to turn into a training prescription. We can’t use it to identify a dangerous number of weekly intervals, a protective heart-rate ceiling, or a mileage limit.
I would also be cautious about the observation that calcium increased while these men kept exercising. Aging also occurred during those six years. Without an appropriate comparison, that change alone cannot tell us how their arteries would have fared had they stopped training.
Hard Exercise Can Also Improve Plaque
A randomized trial offers a useful counterpoint.
The CENIT study assigned 60 patients with stable coronary artery disease to supervised high-intensity interval training or usual preventive care; 59 were included in the analyses. Participants had undergone coronary intervention and were receiving stable lipid-lowering treatment.
For six months, the exercise group completed two supervised sessions weekly, including four four-minute intervals at 85–95% of peak heart rate.
Researchers used ultrasound inside the coronary arteries to measure plaque. Average percent atheroma volume—the proportion of the measured vessel volume occupied by plaque—fell by 1.2 percentage points in the interval group. The between-group difference was 1.4 percentage points in favor of training, with a 95% confidence interval of 0.1–2.7 points.7Elisabeth Kleivhaug Vesterbekkmo, Inger-Lise Aamot Aksetøy, Turid Follestad, Hans Olav Nilsen, Knut Hegbom, Ulrik Wisløff, Rune Wiseth, & Madssen, E. (2022). High-intensity interval training induces beneficial effects on coronary atheromatous plaques: A randomized trial. European Journal of Preventive Cardiology, 30(5), 384–392. https://doi.org/10.1093/eurjpc/zwac309
That supports a benefit of supervised training in this clinical setting. It doesn’t establish that adding intervals will reverse plaque in an otherwise healthy marathon runner.
These studies ask different questions. Six months of prescribed exercise in treated patients cannot settle what decades of endurance training do to athletes’ arteries. Nor can an observational association between exercise categories and calcium progression negate a randomized trial showing reduced plaque volume.
I find this more useful than labeling intensity as universally good or bad. The population, dose, treatment context, and outcome all matter.
The Familiar Risk Factors Still Apply
It’s tempting to look for an explanation unique to athletes. Perhaps years of high blood flow, repeated pressure surges, or some training-specific process explain everything.
But a later MARC-2 analysis reminds us that familiar risk factors remain relevant.
Among 289 male athletes, age, systolic blood pressure, smoking history, and family history of coronary artery disease were independently associated with higher calcium scores. Family history showed the strongest association.
Training load and dietary variables also contributed. Lower reported energy intake and a lower percentage of calories from fat were associated with greater calcification. However, the authors considered the analyses exploratory, and some associations weakened in sensitivity analyses.
Those diet findings don’t demonstrate that eating more fat prevents plaque, that carbohydrates cause it, or that underfueling explains the athlete paradox. The study didn’t assign diets or test those mechanisms.8Berge, K., Janssen, S. L. J. E., Velthuis, B. K., Myhre, P. L., Mosterd, A., Omland, T., Eijsvogels, T. M. H., & Aengevaeren, V. L. (2024). Predictors of coronary atherosclerosis in middle-aged and older athletes: The MARC-2 study. European Heart Journal – Cardiovascular Imaging, 26(3), 461–470. https://doi.org/10.1093/ehjci/jeae317
For runners, the practical implication is straightforward: being fit is a reason to value the work you’ve done, while still paying attention to your broader risk profile.
A training log is useful information at a medical appointment. So are blood pressure, cholesterol, smoking history, and family history. One doesn’t replace the others.
A related caution is that a simple blood test can’t reveal hidden plaque. In a 2025 study, researchers measured cardiac troponin before and after endurance events, then scanned 68 high responders and 34 low responders. Troponin marks heart muscle injury, but it can also rise after prolonged exercise.9Janssen, S. L. J. E., van Everdingen, W. M., Saalmink, W. B. J., Lamers, S. K., Vroemen, W. H. M., Denessen, E. J. S., Berge, K., Bekers, O., Hopman, M. T. E., Brink, M., Habets, J., Aengevaeren, V. L., Mingels, A. M. A., Nijveldt, R., Eijsvogels, T. M. H., & TREAT study collaboration. (2025). Relationship between exercise-induced cardiac troponin elevations and occult coronary atherosclerosis in middle-aged athletes. Journal of the American College of Cardiology, 85(24), 2370–2382. https://doi.org/10.1016/j.jacc.2025.04.047
The groups didn’t differ significantly in coronary atherosclerosis prevalence or severity. The estimates were imprecise, so this didn’t prove that no relationship exists. It did suggest that a large exercise-related troponin response is a poor shortcut for identifying hidden plaque.
Once again, different measurements answer different questions.
Plaque Vs. Heart Attacks: What Matters Most
Plaque deserves attention because it helps predict outcomes we care about. But an imaging result and an actual heart attack aren’t the same endpoint.
The broader running literature remains reassuring. In a study of 55,137 adults followed for approximately 15 years, runners had 30% lower adjusted all-cause mortality and 45% lower cardiovascular mortality than nonrunners.
Because this was observational research, those percentages shouldn’t be treated as a guaranteed benefit for an individual. It also wasn’t a definitive test of lifelong extreme training. Still, it provides substantial evidence that running is associated with better long-term outcomes.10Lee, D., Pate, R. R., Lavie, C. J., Sui, X., Church, T. S., & Blair, S. N. (2014). Leisure-time running reduces all-cause and cardiovascular mortality risk. Journal of the American College of Cardiology, 64(5), 472–481. https://doi.org/10.1016/j.jacc.2014.04.058
A separate study addressed the calcium question more directly. Researchers followed 21,758 generally healthy men for an average of 10.4 years. The most active men were somewhat more likely to have CAC scores of at least 100, yet high activity wasn’t associated with higher all-cause or cardiovascular mortality.
Among men with CAC of at least 100, the most active group had an estimated all-cause mortality hazard ratio of 0.77 relative to the least active group. The confidence interval (0.52–1.15) included no difference. That supports reassurance against a large mortality penalty, while stopping short of proving that high activity eliminated the risk associated with calcium.11DeFina, L. F., Radford, N. B., Barlow, C. E., Willis, B. L., Leonard, D., Haskell, W. L., Farrell, S. W., Pavlovic, A., Abel, K., Berry, J. D., Khera, A., & Levine, B. D. (2019). Association of all-cause and cardiovascular mortality with high levels of physical activity and concurrent coronary artery calcification. JAMA Cardiology, 4(2), 174. https://doi.org/10.1001/jamacardio.2018.4628
This is where I land: the evidence supports continuing to value endurance exercise while taking coronary disease seriously.
Exercise can still improve overall cardiovascular outcomes without preventing every component of atherosclerosis. We don’t need to assume plaque is harmless to recognize the benefits of training. And we don’t need to interpret every abnormal scan as evidence that running was a mistake.
What we still need is better long-term follow-up of athletes with carefully characterized training histories and plaque, including far more women and more diverse populations. Broad mortality studies are reassuring, but they don’t answer every question about the highest training exposures.
For now, I would use this research to change how we think about prevention, not to rewrite a training plan.
Keep the benefits of fitness in view. Give conventional risk factors the attention they deserve. If coronary plaque has been identified, interpret it with a clinician in the context of your overall health and training.
The distinction I keep coming back to is simple: running can substantially improve your cardiovascular outlook without making you immune to cardiovascular disease.
I still intend to keep running for a very long time. Understanding that distinction seems like part of making that possible.
References
- 1Spencer, L. W., Flannery, M. D., Janssens, K., Bekhuis, Y., Wright, L., Howden, E. J., Van Puyvelde, T., Prior, D. L., Mitchell, A. M., Rowe, S. J., Foulkes, S. J., & La Gerche, A. (2026). A race against time: Timing constraints of cardiac filling and athletic performance. American Journal of Physiology-Heart and Circulatory Physiology, 330(5), H1423–H1432. https://doi.org/10.1152/ajpheart.00896.2025↩︎
- 2Aengevaeren, V. L., Mosterd, A., Bakker, E. A., Braber, T. L., Nathoe, H. M., Sharma, S., Thompson, P. D., Velthuis, B. K., & Eijsvogels, T. M. H. (2023). Exercise volume versus intensity and the progression of coronary atherosclerosis in middle-aged and older athletes: Findings from the MARC-2 study. Circulation, 147(13), 993–1003. https://doi.org/10.1161/circulationaha.122.061173↩︎
- 3Aengevaeren, V. L., Mosterd, A., Braber, T. L., Prakken, N. H. J., Doevendans, P. A., Grobbee, D. E., Thompson, P. D., Eijsvogels, T. M. H., & Velthuis, B. K. (2017). Relationship between lifelong exercise volume and coronary atherosclerosis in athletes. Circulation, 136(2), 138–148. https://doi.org/10.1161/circulationaha.117.027834↩︎
- 4De Bosscher, R., Dausin, C., Claus, P., Bogaert, J., Dymarkowski, S., Goetschalckx, K., Ghekiere, O., Van De Heyning, C. M., Van Herck, P., Paelinck, B., Addouli, H. El, La Gerche, A., Herbots, L., Willems, R., Heidbuchel, H., & Claessen, G. (2023). Lifelong endurance exercise and its relation with coronary atherosclerosis. European Heart Journal, 44(26), 2388–2399. https://doi.org/10.1093/eurheartj/ehad152↩︎
- 5Aengevaeren, V. L., Mosterd, A., Bakker, E. A., Braber, T. L., Nathoe, H. M., Sharma, S., Thompson, P. D., Velthuis, B. K., & Eijsvogels, T. M. H. (2023). Exercise volume versus intensity and the progression of coronary atherosclerosis in middle-aged and older athletes: Findings from the MARC-2 study. Circulation, 147(13), 993–1003. https://doi.org/10.1161/circulationaha.122.061173↩︎
- 6Aengevaeren, VL, Mosterd, A., Ea, B., Braber, TL, Nathoe, HM, Sharma, S., Thompson, PD, Velthuis, BK, & Eijsvogels, TMH. (2023, March 28). Exercise volume versus intensity and the progression of coronary atherosclerosis in middle-aged and older athletes: Findings from the MARC-2 study. – SORA. Sgul.Ac.Uk. https://openaccess.sgul.ac.uk/id/eprint/115139/↩︎
- 7Elisabeth Kleivhaug Vesterbekkmo, Inger-Lise Aamot Aksetøy, Turid Follestad, Hans Olav Nilsen, Knut Hegbom, Ulrik Wisløff, Rune Wiseth, & Madssen, E. (2022). High-intensity interval training induces beneficial effects on coronary atheromatous plaques: A randomized trial. European Journal of Preventive Cardiology, 30(5), 384–392. https://doi.org/10.1093/eurjpc/zwac309↩︎
- 8Berge, K., Janssen, S. L. J. E., Velthuis, B. K., Myhre, P. L., Mosterd, A., Omland, T., Eijsvogels, T. M. H., & Aengevaeren, V. L. (2024). Predictors of coronary atherosclerosis in middle-aged and older athletes: The MARC-2 study. European Heart Journal – Cardiovascular Imaging, 26(3), 461–470. https://doi.org/10.1093/ehjci/jeae317↩︎
- 9Janssen, S. L. J. E., van Everdingen, W. M., Saalmink, W. B. J., Lamers, S. K., Vroemen, W. H. M., Denessen, E. J. S., Berge, K., Bekers, O., Hopman, M. T. E., Brink, M., Habets, J., Aengevaeren, V. L., Mingels, A. M. A., Nijveldt, R., Eijsvogels, T. M. H., & TREAT study collaboration. (2025). Relationship between exercise-induced cardiac troponin elevations and occult coronary atherosclerosis in middle-aged athletes. Journal of the American College of Cardiology, 85(24), 2370–2382. https://doi.org/10.1016/j.jacc.2025.04.047↩︎
- 10Lee, D., Pate, R. R., Lavie, C. J., Sui, X., Church, T. S., & Blair, S. N. (2014). Leisure-time running reduces all-cause and cardiovascular mortality risk. Journal of the American College of Cardiology, 64(5), 472–481. https://doi.org/10.1016/j.jacc.2014.04.058↩︎
- 11DeFina, L. F., Radford, N. B., Barlow, C. E., Willis, B. L., Leonard, D., Haskell, W. L., Farrell, S. W., Pavlovic, A., Abel, K., Berry, J. D., Khera, A., & Levine, B. D. (2019). Association of all-cause and cardiovascular mortality with high levels of physical activity and concurrent coronary artery calcification. JAMA Cardiology, 4(2), 174. https://doi.org/10.1001/jamacardio.2018.4628↩︎
Join 300,000+ runners in RunClub
Free training plans for every distance, a daily running game, exclusive coaching content, and a real community of runners. Create your free account in 20 seconds — no card.
‘;
pfOverlay.addEventListener(‘click’, function(e){ if (e.target === pfOverlay || e.target.closest(‘.rc-news__pf-close’)) pfOverlay.style.display=’none’; });
document.body.appendChild(pfOverlay);
}
pfOverlay.querySelector(‘.rc-news__pf-body’).innerHTML = r.data.html;
pfOverlay.style.display = ‘flex’;
}).catch(function(){});
}
root.addEventListener(‘click’, function(e){
var a = e.target.closest(‘.rc-news__author’); if (!a) return;
e.preventDefault(); openProfile(a.getAttribute(‘data-user’));
});
// Reply targeting (composer lives outside the re-rendered box).
var pill = document.getElementById(‘rc-artc-reply-pill’);
var pillName = document.getElementById(‘rc-artc-reply-to’);
var input = document.getElementById(‘rc-artc-input’);
var formEl = document.getElementById(‘rc-artc-composer’);
function setReply(pid, name){ replyParent = parseInt(pid,10)||0; if (replyParent && pill){ if (pillName) pillName.textContent = name||’comment’; pill.style.display=”; } if (input) input.focus(); }
function clearReply(){ replyParent = 0; if (pill) pill.style.display=’none’; }
var rcx = document.getElementById(‘rc-artc-reply-cancel’); if (rcx) rcx.addEventListener(‘click’, clearReply);
box.addEventListener(‘click’, function(e){
var b = e.target.closest(‘.rc-news__reply-btn’); if (!b) return;
setReply(b.getAttribute(‘data-parent’), b.getAttribute(‘data-name’));
if (formEl) formEl.scrollIntoView({block:’nearest’});
});
// Show-all (load the full thread).
box.addEventListener(‘click’, function(e){
var s = e.target.closest(‘.rc-artc__showall’); if (!s) return;
s.disabled = true;
post(‘mh_artc_thread’, {post_id:postId, sort:currentSort, all:1}).then(function(r){ if (r.success && r.data.html) box.innerHTML = r.data.html; }).catch(function(){ s.disabled=false; });
});
// Sort tabs.
Array.prototype.forEach.call(document.querySelectorAll(‘#rc-artc .rc-news__sort’), function(tab){
tab.addEventListener(‘click’, function(){
var ss = tab.getAttribute(‘data-sort’); if (ss === currentSort) return;
currentSort = ss;
Array.prototype.forEach.call(document.querySelectorAll(‘#rc-artc .rc-news__sort’), function(t){ t.classList.toggle(‘is-active’, t===tab); });
post(‘mh_artc_thread’, {post_id:postId, sort:currentSort, all:1}).then(function(r){ if (r.success && r.data.html) box.innerHTML = r.data.html; }).catch(function(){});
});
});
// Composer: emoji (all) + member image upload + submit.
var msg = document.getElementById(‘rc-artc-composer-msg’);
var mediaIds = [];
if (formEl){
var emojiBtn = document.getElementById(‘rc-artc-emoji-btn’);
var emojiPop = document.getElementById(‘rc-artc-emoji-pop’);
var emojiLoaded = false;
if (emojiBtn) emojiBtn.addEventListener(‘click’, function(){
if (!emojiLoaded){ emojiLoaded = true;
var sc = document.createElement(‘script’); sc.type=’module’; sc.src=’https://cdn.jsdelivr.net/npm/emoji-picker-element@1/index.js’; document.head.appendChild(sc);
var picker = document.createElement(’emoji-picker’);
picker.addEventListener(’emoji-click’, function(ev){
var u = ev.detail && ev.detail.unicode; if (!u) return;
var s0 = input.selectionStart||0, s1 = input.selectionEnd||0;
input.value = input.value.slice(0,s0) + u + input.value.slice(s1);
input.focus(); input.selectionStart = input.selectionEnd = s0 + u.length;
});
emojiPop.appendChild(picker);
}
emojiPop.hidden = !emojiPop.hidden;
});
var preview = document.getElementById(‘rc-artc-media-preview’);
var attachBtn = document.getElementById(‘rc-artc-attach-btn’);
var fileInput = document.getElementById(‘rc-artc-file’);
function renderPreview(){ if (!preview) return; preview.innerHTML=”; mediaIds.forEach(function(m){ var d=document.createElement(‘div’); d.className=’rc-news__pv’; d.innerHTML=’
‘; preview.appendChild(d); }); }
if (attachBtn && fileInput){
attachBtn.addEventListener(‘click’, function(){ fileInput.click(); });
if (preview) preview.addEventListener(‘click’, function(e){ var x=e.target.closest(‘.rc-news__pv-x’); if (!x) return; mediaIds=mediaIds.filter(function(m){ return String(m.id)!==String(x.getAttribute(‘data-id’)); }); renderPreview(); });
fileInput.addEventListener(‘change’, function(){
var files = Array.prototype.slice.call(fileInput.files||[]); fileInput.value=”;
files.forEach(function(file){
if (mediaIds.length >= 4) return;
var ph = document.createElement(‘div’); ph.className=’rc-news__pv is-loading’; ph.textContent=’…’; preview.appendChild(ph);
var fd = new FormData(); fd.append(‘action’,’mh_newsroom_upload’); fd.append(‘nonce’,upnonce); fd.append(‘file’,file);
fetch(ajax,{method:’POST’,body:fd,credentials:’same-origin’}).then(function(r){return r.json();}).then(function(r){
ph.remove();
if (r.success){ mediaIds.push({id:r.data.id, url:r.data.url}); renderPreview(); }
else { msg.className=’rc-news__composer-msg is-err’; msg.textContent=(r.data||’Upload failed.’); }
}).catch(function(){ ph.remove(); });
});
});
}
var btn = formEl.querySelector(‘.rc-news__send’);
var authorEl = document.getElementById(‘rc-artc-author’);
var emailEl = document.getElementById(‘rc-artc-email’);
formEl.addEventListener(‘submit’, function(e){
e.preventDefault();
var content = (input.value||”).trim();
if (!content){ msg.className=’rc-news__composer-msg is-err’; msg.textContent=’Write something first.’; return; }
var payload = {post_id:postId, content:content, parent:replyParent, sort:currentSort, all:1};
if (authorEl) payload.author = authorEl.value;
if (emailEl) payload.email = emailEl.value;
if (mediaIds.length) payload.media = mediaIds.map(function(m){ return m.id; });
btn.disabled = true; msg.className=’rc-news__composer-msg’; msg.textContent=’Posting…’;
post(‘mh_artc_comment’, payload).then(function(r){
btn.disabled = false;
if (r.success){
input.value=”; clearReply(); mediaIds=[]; if (preview) preview.innerHTML=”;
box.innerHTML = r.data.html;
msg.className=’rc-news__composer-msg is-ok’; msg.textContent = r.data.approved ? ‘Posted.’ : ‘Posted — awaiting moderation.’;
setTimeout(function(){ msg.textContent=”; }, 5000);
} else {
msg.className=’rc-news__composer-msg is-err’; msg.textContent = (r.data || ‘Could not post.’);
}
}).catch(function(err){ btn.disabled=false; msg.className=’rc-news__composer-msg is-err’; msg.textContent=’Error: ‘+err.message; });
});
}
})();
