SlideShare a Scribd company logo
1 of 19
Download to read offline
Responsive Web Design
tehnike u WordPressu
Igor Benić WP Meetup Zagreb 19.09
Sadržaj
• O meni
• Što je RWD?
• Izrada RWD-a
• Slike u RWD-u
• WordPress i RWD
• Slike u WordPress-u
• WordPress Mobile
• Pitanja
O meni
• Front End Developer @ Multilink
• Co-founder – www.lakotuts.com
• PSD -> PHP
• Autor knjige: WordPress na Bootstrap-u 3.x
O meni
• Bootstrap 3
• Izrada osnovne i naprednih tema
• Customizer API
• Settings API
• AJAX
http://leanpub.com/wpb3
Što je RWD?
• Stranica (sadržaj) se prilagođava ekranu
– Točke izmjene
• Vrste RWD-a
– Responsive
– Adaptive
• Sadržaj
• Brzina
Izrada RWD-a
• Mobile First
• Desktop First
• Korištenje Alata
• CSS od nule
• Korištenje Frameworka
Načini izrade - Framework
• Bootstrap 3
• Foundation
• Skeleton
• Gumby
• Mnogi drugi
Slike u RWD-u
• Nisu jednostavne
– Servirati samo potrebnu sliku
– Paziti i na Retina ekrane
• Moguća rješenja
– Picturefill 2.0
– BttrLazyLoading
Slike u RWD-u – PictureFill 2.0
<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source srcset="examples/images/extralarge.jpg" media="(min-
width: 1000px)">
<source srcset="examples/images/large.jpg" media="(min-width:
800px)">
<source srcset="examples/images/large@2.jpg" media="(min-
width: 800px) and (-webkit-min-device-pixel-ratio: 2)">
<!--[if IE 9]></video><![endif]-->
<img srcset="examples/images/medium.jpg" alt="A giant stone
face at The Bayon temple in Angkor Thom, Cambodia">
</picture>
Slike u RWD-u – BttrLazyLoading
<img id="yourImageId" class="bttrlazyloading"
data-bttrlazyloading-xs-src="img/768x200.gif"
data-bttrlazyloading-xs-width="768"
data-bttrlazyloading-xs-height="200"
data-bttrlazyloading-sm-src="img/345x250.gif"
data-bttrlazyloading-sm-width="345"
data-bttrlazyloading-sm-height="250"
data-bttrlazyloading-md-src="img/455x350.gif"
data-bttrlazyloading-md-width="455"
data-bttrlazyloading-md-height="350" d
data-bttrlazyloading-lg-src="img/360x300.gif"
data-bttrlazyloading-lg-width="360"
data-bttrlazyloading-lg-height="300" />
WordPress i RWD
RESS
Pružanje sadržaja ovisno o uređaju
Prilagodba sadržaja na serveru
Slike u WordPress-u
• Različite verzije za istu sliku
– add_image_size(“verzija”, širina, visina, [true |
false]);
• add_filter(“post_thumbnail”,
funkcija_za_promjenu);
Slike u WordPress-u - Thumbnailovifunction wpb3_thumbnail_html($html, $post_id, $aid, $sizeThumb, $attr){
if($sizeThumb == "slika-clanka"){
$sizes = array('slika-clanka‘, 'slika-clanka-md‘, 'slika-clanka-sm‘, 'slika-clanka-xs’);
$img = "<img class='bttrLazyLoading img-responsive' alt='".get_the_title()."'";
$sizeBttr = "";
$width = "";
$height = "";
$aid = (!$aid) ? get_post_thumbnail_id() : $aid;
foreach ( $sizes as $size ) {
$url = wp_get_attachment_image_src( $aid, $size );
switch ($size) {
case 'slika-clanka':
$sizeBttr = "lg";
$width = "750";
$height= "353";
break;
...
}
$img .= " data-bttrlazyloading-".$sizeBttr."-src='". $url[0] ."' ";
$img .= " data-bttrlazyloading-".$sizeBttr."-width='". $width ."' ";
$img .= " data-bttrlazyloading-".$sizeBttr."-height='". $height ."' ";
}
$img .= " />";
return $img;
}
return $html;
}
add_filter(
'post_thumbnail_html',
'wpb3_thumbnail_html', 10, 5);
Slike u WordPress-u - Content
• Filtrirati slike prilikom ispisa ili obrisati (na mobitelima)
– add_filter(‘the_content’, ‘funkcija za filtriranje slika’)
• CSS:
– .post img {max-width:100%;height:auto;}
function slike_u_content() {
global $post;
$html = preg_replace_callback( '#(<imgs[^>]*src)="([^"]+)"#', "callback_img",
get_the_content($post->ID) );
return $html;
}
function callback_img($match) {
list(, $img, $src) = $match;
$url = get_stylesheet_directory_uri().'/img_placeholder.gif';
return "$img="$url" data-href="$src" ";
}
Slike u WordPress-u - LakoTuts
• Filtrirati slike prilikom ispisa
– add_filter(‘the_content’, ‘funkcija za filtriranje slika’)
• CSS:
– .post img {max-width:100%;height:auto;}
$attachment_id = lakotuts_get_attachment_id_from_url($header_image);
$image480 = wp_get_attachment_image_src( $attachment_id, 'image480' );
$image768 = wp_get_attachment_image_src( $attachment_id, 'image768' );
$image1024 = wp_get_attachment_image_src( $attachment_id, 'image1024' );
$image1920 = wp_get_attachment_image_src( $attachment_id, 'image1920' );
echo ‘ #masthead { background-image: url(''. $image768[0] .''); } ';
echo '@media (min-width:768px) { #masthead { background-image: url(''. $image768[0] .''); }}';
echo '@media (min-width:1024px) { #masthead { background-image: url(''. $image1024[0] .''); }}';
echo '@media (min-width:1200px) { #masthead { background-image: url(''. $image1920[0] .''); }}';
WordPress Mobile
• wp_mobile()
• WURFL baza podataka
• github.com/jcasabona/wp-ress/
WordPress Mobile
function wpr_detect_mobile_device(){
try{
$config = new WurflCloud_Client_Config();
$config->api_key = WPR_API_KEY;
$client = new WurflCloud_Client_Client($config);
$client->detectDevice();
return $client->getDeviceCapability('is_wireless_device');
}
catch (Exception $e){
return wp_is_mobile();
}
}
define('WPR_IS_MOBILE', wpr_detect_mobile_device());
WordPress Mobile
• Izbornici za Desktop i Mobitele/Tablete
– Izbjegnut dvostruki HTML sadržaj
• Prikaz pojedinog sadržaja samo na zahtjev
– Komentari
– Sidebar
Pitanja
?

More Related Content

What's hot

Be German About Your Frontend
Be German About Your FrontendBe German About Your Frontend
Be German About Your Frontend
Arush Sehgal
 
Sadielai10x10presentation
Sadielai10x10presentationSadielai10x10presentation
Sadielai10x10presentation
sadielai
 

What's hot (20)

Be German About Your Frontend
Be German About Your FrontendBe German About Your Frontend
Be German About Your Frontend
 
Front-end Rails-приложений приложений, основанный на БЭМ
Front-end Rails-приложений приложений, основанный на БЭМFront-end Rails-приложений приложений, основанный на БЭМ
Front-end Rails-приложений приложений, основанный на БЭМ
 
Dr. Strangelove or: How I learned to stop worrying and love HTML, CSS and Jav...
Dr. Strangelove or: How I learned to stop worrying and love HTML, CSS and Jav...Dr. Strangelove or: How I learned to stop worrying and love HTML, CSS and Jav...
Dr. Strangelove or: How I learned to stop worrying and love HTML, CSS and Jav...
 
Whirlwind Tour of SVG (plus RaphaelJS)
Whirlwind Tour of SVG (plus RaphaelJS)Whirlwind Tour of SVG (plus RaphaelJS)
Whirlwind Tour of SVG (plus RaphaelJS)
 
dojo.Patterns
dojo.Patternsdojo.Patterns
dojo.Patterns
 
Yuihacku iitd-sumana
Yuihacku iitd-sumanaYuihacku iitd-sumana
Yuihacku iitd-sumana
 
Css3
Css3Css3
Css3
 
AngularJS: The Bridge Between Today and Tomorrow's Web (Todd Motto)
AngularJS: The Bridge Between Today and Tomorrow's Web (Todd Motto)AngularJS: The Bridge Between Today and Tomorrow's Web (Todd Motto)
AngularJS: The Bridge Between Today and Tomorrow's Web (Todd Motto)
 
Tide - The missing web framework
Tide - The missing web frameworkTide - The missing web framework
Tide - The missing web framework
 
Fundamental JQuery
Fundamental JQueryFundamental JQuery
Fundamental JQuery
 
Best Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStart
Best Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStartBest Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStart
Best Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStart
 
Sadielai10x10presentation
Sadielai10x10presentationSadielai10x10presentation
Sadielai10x10presentation
 
Thinkin' Tags - Rapid Prototyping of CSS Layouts
Thinkin' Tags - Rapid Prototyping of CSS LayoutsThinkin' Tags - Rapid Prototyping of CSS Layouts
Thinkin' Tags - Rapid Prototyping of CSS Layouts
 
Introduction to Web Design, Week 1
Introduction to Web Design, Week 1Introduction to Web Design, Week 1
Introduction to Web Design, Week 1
 
Real World Web components
Real World Web componentsReal World Web components
Real World Web components
 
An in-depth look at jQuery UI
An in-depth look at jQuery UIAn in-depth look at jQuery UI
An in-depth look at jQuery UI
 
WordPress Theme Workshop: CSS/JS
WordPress Theme Workshop: CSS/JSWordPress Theme Workshop: CSS/JS
WordPress Theme Workshop: CSS/JS
 
Front End Tooling and Performance - Codeaholics HK 2015
Front End Tooling and Performance - Codeaholics HK 2015Front End Tooling and Performance - Codeaholics HK 2015
Front End Tooling and Performance - Codeaholics HK 2015
 
Sami world travel
Sami world travelSami world travel
Sami world travel
 
JavaScript the Smart Way - Getting Started with jQuery
JavaScript the Smart Way - Getting Started with jQueryJavaScript the Smart Way - Getting Started with jQuery
JavaScript the Smart Way - Getting Started with jQuery
 

Viewers also liked

Viewers also liked (12)

Instalacija i podešavanje word press bloga
Instalacija i podešavanje word press blogaInstalacija i podešavanje word press bloga
Instalacija i podešavanje word press bloga
 
WordPress za početnike
WordPress za početnikeWordPress za početnike
WordPress za početnike
 
Šta je Bootstrap?
Šta je Bootstrap?Šta je Bootstrap?
Šta je Bootstrap?
 
Projektovanje web aplikacija
Projektovanje web aplikacijaProjektovanje web aplikacija
Projektovanje web aplikacija
 
WordPress teme za početnike - uvod u Theme Development
WordPress teme za početnike - uvod u Theme DevelopmentWordPress teme za početnike - uvod u Theme Development
WordPress teme za početnike - uvod u Theme Development
 
Wordpress - Sistem za upravljanje sadržajem na webu
Wordpress - Sistem za upravljanje sadržajem na webuWordpress - Sistem za upravljanje sadržajem na webu
Wordpress - Sistem za upravljanje sadržajem na webu
 
Profiling php5 to php7
Profiling php5 to php7Profiling php5 to php7
Profiling php5 to php7
 
Starenje softvera
Starenje softveraStarenje softvera
Starenje softvera
 
Uvod u funkcionalno programiranje
Uvod u funkcionalno programiranjeUvod u funkcionalno programiranje
Uvod u funkcionalno programiranje
 
Refaktorisanje
RefaktorisanjeRefaktorisanje
Refaktorisanje
 
Uvod u objektno orijentisano programiranje i C++
Uvod u objektno orijentisano programiranje i C++Uvod u objektno orijentisano programiranje i C++
Uvod u objektno orijentisano programiranje i C++
 
Uvod u softversko inženjerstvo
Uvod u softversko inženjerstvoUvod u softversko inženjerstvo
Uvod u softversko inženjerstvo
 

Similar to Responsive Web Design tehnike u WordPress-u

建立前端開發團隊 - 2011 中華電信訓練所版
建立前端開發團隊 - 2011 中華電信訓練所版建立前端開發團隊 - 2011 中華電信訓練所版
建立前端開發團隊 - 2011 中華電信訓練所版
Joseph Chiang
 
WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1
Yoav Farhi
 
125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용
NAVER D2
 

Similar to Responsive Web Design tehnike u WordPress-u (20)

以Vue開發電子商務網站
架構與眉角
以Vue開發電子商務網站
架構與眉角以Vue開發電子商務網站
架構與眉角
以Vue開發電子商務網站
架構與眉角
 
Word Press As A Cms
Word Press As A CmsWord Press As A Cms
Word Press As A Cms
 
Death of a Themer
Death of a ThemerDeath of a Themer
Death of a Themer
 
You're Doing it Wrong - WordCamp Atlanta
You're Doing it Wrong - WordCamp AtlantaYou're Doing it Wrong - WordCamp Atlanta
You're Doing it Wrong - WordCamp Atlanta
 
建立前端開發團隊 - 2011 中華電信訓練所版
建立前端開發團隊 - 2011 中華電信訓練所版建立前端開發團隊 - 2011 中華電信訓練所版
建立前端開發團隊 - 2011 中華電信訓練所版
 
RESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsRESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side Components
 
CSS and image optimization
CSS and image optimizationCSS and image optimization
CSS and image optimization
 
WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
bcgr3-jquery
bcgr3-jquerybcgr3-jquery
bcgr3-jquery
 
bcgr3-jquery
bcgr3-jquerybcgr3-jquery
bcgr3-jquery
 
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and CompassBringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 
From PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to lifeFrom PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to life
 
Rails3 asset-pipeline
Rails3 asset-pipelineRails3 asset-pipeline
Rails3 asset-pipeline
 
125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용
 
Membuat slide show pada posting
Membuat slide show pada postingMembuat slide show pada posting
Membuat slide show pada posting
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
 
Mobile themes, QR codes, and shortURLs
Mobile themes, QR codes, and shortURLsMobile themes, QR codes, and shortURLs
Mobile themes, QR codes, and shortURLs
 
Drupal as a web framework
Drupal as a web frameworkDrupal as a web framework
Drupal as a web framework
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Responsive Web Design tehnike u WordPress-u

  • 1. Responsive Web Design tehnike u WordPressu Igor Benić WP Meetup Zagreb 19.09
  • 2. Sadržaj • O meni • Što je RWD? • Izrada RWD-a • Slike u RWD-u • WordPress i RWD • Slike u WordPress-u • WordPress Mobile • Pitanja
  • 3. O meni • Front End Developer @ Multilink • Co-founder – www.lakotuts.com • PSD -> PHP • Autor knjige: WordPress na Bootstrap-u 3.x
  • 4. O meni • Bootstrap 3 • Izrada osnovne i naprednih tema • Customizer API • Settings API • AJAX http://leanpub.com/wpb3
  • 5. Što je RWD? • Stranica (sadržaj) se prilagođava ekranu – Točke izmjene • Vrste RWD-a – Responsive – Adaptive • Sadržaj • Brzina
  • 6. Izrada RWD-a • Mobile First • Desktop First • Korištenje Alata • CSS od nule • Korištenje Frameworka
  • 7. Načini izrade - Framework • Bootstrap 3 • Foundation • Skeleton • Gumby • Mnogi drugi
  • 8. Slike u RWD-u • Nisu jednostavne – Servirati samo potrebnu sliku – Paziti i na Retina ekrane • Moguća rješenja – Picturefill 2.0 – BttrLazyLoading
  • 9. Slike u RWD-u – PictureFill 2.0 <picture> <!--[if IE 9]><video style="display: none;"><![endif]--> <source srcset="examples/images/extralarge.jpg" media="(min- width: 1000px)"> <source srcset="examples/images/large.jpg" media="(min-width: 800px)"> <source srcset="examples/images/large@2.jpg" media="(min- width: 800px) and (-webkit-min-device-pixel-ratio: 2)"> <!--[if IE 9]></video><![endif]--> <img srcset="examples/images/medium.jpg" alt="A giant stone face at The Bayon temple in Angkor Thom, Cambodia"> </picture>
  • 10. Slike u RWD-u – BttrLazyLoading <img id="yourImageId" class="bttrlazyloading" data-bttrlazyloading-xs-src="img/768x200.gif" data-bttrlazyloading-xs-width="768" data-bttrlazyloading-xs-height="200" data-bttrlazyloading-sm-src="img/345x250.gif" data-bttrlazyloading-sm-width="345" data-bttrlazyloading-sm-height="250" data-bttrlazyloading-md-src="img/455x350.gif" data-bttrlazyloading-md-width="455" data-bttrlazyloading-md-height="350" d data-bttrlazyloading-lg-src="img/360x300.gif" data-bttrlazyloading-lg-width="360" data-bttrlazyloading-lg-height="300" />
  • 11. WordPress i RWD RESS Pružanje sadržaja ovisno o uređaju Prilagodba sadržaja na serveru
  • 12. Slike u WordPress-u • Različite verzije za istu sliku – add_image_size(“verzija”, širina, visina, [true | false]); • add_filter(“post_thumbnail”, funkcija_za_promjenu);
  • 13. Slike u WordPress-u - Thumbnailovifunction wpb3_thumbnail_html($html, $post_id, $aid, $sizeThumb, $attr){ if($sizeThumb == "slika-clanka"){ $sizes = array('slika-clanka‘, 'slika-clanka-md‘, 'slika-clanka-sm‘, 'slika-clanka-xs’); $img = "<img class='bttrLazyLoading img-responsive' alt='".get_the_title()."'"; $sizeBttr = ""; $width = ""; $height = ""; $aid = (!$aid) ? get_post_thumbnail_id() : $aid; foreach ( $sizes as $size ) { $url = wp_get_attachment_image_src( $aid, $size ); switch ($size) { case 'slika-clanka': $sizeBttr = "lg"; $width = "750"; $height= "353"; break; ... } $img .= " data-bttrlazyloading-".$sizeBttr."-src='". $url[0] ."' "; $img .= " data-bttrlazyloading-".$sizeBttr."-width='". $width ."' "; $img .= " data-bttrlazyloading-".$sizeBttr."-height='". $height ."' "; } $img .= " />"; return $img; } return $html; } add_filter( 'post_thumbnail_html', 'wpb3_thumbnail_html', 10, 5);
  • 14. Slike u WordPress-u - Content • Filtrirati slike prilikom ispisa ili obrisati (na mobitelima) – add_filter(‘the_content’, ‘funkcija za filtriranje slika’) • CSS: – .post img {max-width:100%;height:auto;} function slike_u_content() { global $post; $html = preg_replace_callback( '#(<imgs[^>]*src)="([^"]+)"#', "callback_img", get_the_content($post->ID) ); return $html; } function callback_img($match) { list(, $img, $src) = $match; $url = get_stylesheet_directory_uri().'/img_placeholder.gif'; return "$img="$url" data-href="$src" "; }
  • 15. Slike u WordPress-u - LakoTuts • Filtrirati slike prilikom ispisa – add_filter(‘the_content’, ‘funkcija za filtriranje slika’) • CSS: – .post img {max-width:100%;height:auto;} $attachment_id = lakotuts_get_attachment_id_from_url($header_image); $image480 = wp_get_attachment_image_src( $attachment_id, 'image480' ); $image768 = wp_get_attachment_image_src( $attachment_id, 'image768' ); $image1024 = wp_get_attachment_image_src( $attachment_id, 'image1024' ); $image1920 = wp_get_attachment_image_src( $attachment_id, 'image1920' ); echo ‘ #masthead { background-image: url(''. $image768[0] .''); } '; echo '@media (min-width:768px) { #masthead { background-image: url(''. $image768[0] .''); }}'; echo '@media (min-width:1024px) { #masthead { background-image: url(''. $image1024[0] .''); }}'; echo '@media (min-width:1200px) { #masthead { background-image: url(''. $image1920[0] .''); }}';
  • 16. WordPress Mobile • wp_mobile() • WURFL baza podataka • github.com/jcasabona/wp-ress/
  • 17. WordPress Mobile function wpr_detect_mobile_device(){ try{ $config = new WurflCloud_Client_Config(); $config->api_key = WPR_API_KEY; $client = new WurflCloud_Client_Client($config); $client->detectDevice(); return $client->getDeviceCapability('is_wireless_device'); } catch (Exception $e){ return wp_is_mobile(); } } define('WPR_IS_MOBILE', wpr_detect_mobile_device());
  • 18. WordPress Mobile • Izbornici za Desktop i Mobitele/Tablete – Izbjegnut dvostruki HTML sadržaj • Prikaz pojedinog sadržaja samo na zahtjev – Komentari – Sidebar