Photons don’t really “travel” at all. They are just units of energy exchange between the electromagnetic field and other fields such as that of the electron (or any other charged “particle”) and only “exist” at the events (positions and times) of energy transfer, by “emission”, into or, by “absorption”, out of the EM field.
It is only after an emission and absorption event have both been observed that we describe the process as corresponding to the motion of a photon, but really all that has happened might just as well be described by saying that a wave of changes in the EM field propagated from the emission event, and that at any point in spacetime (given the presence of a suitably excitable atom), the probability of an absorption event is proportional to the magnitude of the appropriate frequency component in the EM field at that point in space and time.
But the propagation of the EM field obeys Maxwell’s equations in empty space, and through a medium which can be approximated as consisting of classical particles it is governed by the same equations but with reflected waves from all the particles interfering with one another in such a way that the overall effect is like a wave moving more slowly. So there is something like the “bouncing of all the electrons idea” going on even in the classical case.
Also, the propagation of disturbances in the EM field from one point at one time to another point at a later time can be calculated by a process which amounts to considering all possible paths by which an imagined particle could end up at the right place and time (taking into account all of the ways that imagined particle could bounce off other things in its environment), and using something like a sum of contributions from all such paths to give the field values at the later event. So although there isn’t actually any particular path followed by any real photon, the effect we see is kind of like the average over all possible paths, and the presence of all those electrons allows longer paths to contribute in such a way that the overall effect is as if there was a photon travelling more slowly than it would have if it had only been able to go in a straight line.
Or something like that.
Source: (310) Alan Cooper’s answer to If photons travel at the speed of light in a vacuum, and are said to “slow” when they travel through different media but do they really “slow” or do they just bounce off more atoms and thus travel farther and seem to slow? – Quora