Unfortunately, the Identity and Passport Service do not deal with passport applications from abroad. One of the statements you have to swear on the passport forms (including the one on-line) is that you are in the UK at the time of signing.
Instead, she needs to apply via the British Consulate in Madrid. The only problem I can foresee is that she may not be able to find anyone out there to countersign her photo, but if she gives them a call, they should be able to advise her what to do in her circumstances.