Pro-Conservative newspapers whipped up public anger at the Labour leadership and diverted attention from the many failings of the Conservative party.
The mainstream media crucified Corbyn on a daily basis in a display of partisanship and bias. Corbyn was accused of being unpatriotic, despite Boris Johnson lying to the Queen and attacking Britain's national institutions (including parliament and the BBC). 
The media is rarely favourable to any politician. Anyone that is going to get into national politics knows this and part of the battle during an election campaign is knowing how to manage, and eventually win over the media. Fleet-street has never been an ally of Labour. Yet previous leaders have managed to keep the salivating journalists prowling Westminster’s halls in search of signs of Labour’s demise at bay. Jeremy Corbyn’s failure to effectively manage the media only further underscores his unsuitability for leadership. 
[P1] The media unfairly attacked Corbyn more than Johnson. [P2] This swayed the electorate. [P3] Therefore, the media played a crucial role in Corbyn's defeat.
Rejecting the premises
[Rejecting P1] Corbyn is not unique, the media always attack Labour leaders more than Conservative leaders. Despite this, Corbyn's predecessors overcame the media to secure victory. Therefore, the media did not play a central role in the Labour defeat.