<?php
header('Content-Type:text/javascript');
?>

var encodedArticles = <?= json_encode($articles_data) ?>;
var baseUrl = <?= json_encode(Yii::app()->getBaseUrl(false)); ?>;
for(var i = 0; i < encodedArticles.length; i++){
    if(encodedArticles[i]['image'] != null){
        $('#article-item-' + encodedArticles[i]['id']).css('background', 'url(' + baseUrl + '/uploads/Article/' + encodedArticles[i]['image'] + ') no-repeat 0 0');
        $('#article-item-' + encodedArticles[i]['id']).css('background-size', 'cover');
    }
}