changing image rotation strategy from js to ruby