Dealing with images in a resume form.

Slides:



Advertisements
Similar presentations
Introduction to Web Design Lecture number:. Todays Aim: Introduction to Web-designing and how its done. Modelling websites in HTML.
Advertisements

JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
HTML Basics Customizing your site using the basics of HTML.
Lecture 6/2/12. Forms and PHP The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input When dealing with HTML forms.
Tutorial 6 Creating a Web Form
Images, Tables, lists, blocks, layout, forms, iframes
CHAPTER 30 THE HTML 5 FORMS PROCESSING. LEARNING OBJECTIVES What the three form elements are How to use the HTML 5 tag to specify a list of words’ form.
Tutorial 6 Working with Web Forms
Web Page Behavior IS 373—Web Standards Todd Will.
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
8/16/2015alicewebmaster1 Create contents with the new Content Management System (Drupal): Workflow for page editors.
HTML Tags. Objectives Know the commonly used HTML tags Create a simple webpage using the HTML tags that will be discussed.
Web Content Management Systems. Lecture Contents Web Content Management Systems Non-technical users manage content Workflow management system Different.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
JQuery Page Slider. Our goal is to get to the functionality of the Panic Coda web site.Panic Coda web site.
INFSCI  Last time we built a doggie web page in class following the instructions in the slide deck: Build Web Page with HTML – see week 3 The topics.
Let’s Make An Form! Bonney Armstrong GD 444 Westwood College February 9, 2005.
.  Entertain  Inform  Educate  Blogs  Sell  Date  Gamble  Religion.
Programming in HTML.  Programming Language  Used to design/create web pages  Hyper Text Markup Language  Markup Language  Series of Markup tags 
1 Essential HTML coding By Fadi Safieddine (Week 2)
Images in HTML PowerPoint How images are used in HTML.
Fall 2005 Using FrontPage to Enhance Blackboard - Darek Sady1 Using FrontPage to Enhance Blackboard 1.Introduction 2.Starting FrontPage 3.Creating Documents.
Unit 2, cont. September 12 More HTML. Attributes Some tags are modifiable with attributes This changes the way a tag behaves Modifying a tag requires.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
1 HTML Forms
 HTML is hypertext markup language. It is a way for people to display their information with more complex pictures and text displays. Before HTML, messages.
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
Graduate School of Library and Information Science LIS 753 Introduction to HTML 5 By: Yijun Gao Week Three.
HTML Forms. Slide 2 Forms (Introduction) The purpose of input forms Organizing forms with a and Using different element types to get user input A brief.
CST336, Spring 2015 Week 8: PHP File Upload. PHP provides specific functions to handle binary data such as uploading a file into the server, storing it.
PHP Form Processing * referenced from
More HTML Images and Links. Links An anchor tag (a) is used to define a link, but you also need to add something to the anchor tag – the destination of.
: Information Retrieval อาจารย์ ธีภากรณ์ นฤมาณนลิณี
 Pictures  Page backgrounds  Element backgrounds (list items!)  Link displays (arrows)  List markers.
Tutorial 6 Creating a Web Form
Here are some things you can do while you wait 1.Open your omeka.net site in your browser (e.g. 2.Open.
Your current Moodle 1.9 Minimum Requirements Ability to do a TEST RUN! Upgrading Moodle to Version 2 By Ramzan Jabbar Doncaster College for the Deaf By.
How To Make Easysite Forms By Joshua Crawley Contact:
Joomla Awdhesh Kumar Singsys Pte Ltd. What is Joomla? Joomla is an award-winning content management system (CMS), which enables you to build Web sites.
Lecture 16. A Very Brief Introduction to HTML and XHTML, part V Instructor: Jie Yang Department of Computer Science University of Massachusetts Lowell.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 4.
Migrating Wordpress Migrating Wordpress can sometimes get more complicated as it should. There is no plugin that does this for you, the best way is to.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
Advanced HTML Tags:.
Contributing to the WCARC Website
Images in HTML PowerPoint How images are used in HTML
CARA 3.10 Major New Features
Data Virtualization Tutorial… CORS and CIS
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
AN INTRODUCTORY LESSON TO MAKING A SIMPLE WEB PAGE By: RC Emily Solis
Arrays and files BIS1523 – Lecture 15.
Form Validation and AJAX
PHP Training at GoLogica in Bangalore
Web Programming– UFCFB Lecture 17
Intro to PHP & Variables
Chapter 3 Images.
Images and Backgrounds
DreamWeaver CS4.
MVC Framework, in general.
Colors.
Functions BIS1523 – Lecture 17.
GDSS – Digital Signature
The Ultimate Joomla! Form Builder and Manager
Building Web Applications
IMPORTING SUBMISSIONS
Putting An Image on Your Web Page
Getting started – Example 1
Images in HTML PowerPoint How images are used in HTML
Presentation transcript:

Dealing with images in a resume form

DON’T USE OLD PHP VERSIONS Joomla! 3.8.5 benchmark Requests per second Source: https://kinsta.com/blog/php-7-hhvm-benchmarks/

WHY USE PHP 7? SPEED SECURITY RELIABILITY STAY UP TO DATE. About 60% performance increase – a faster website for your visitors and you. SECURITY Latest version contains security patches, up to date code – you wouldn’t keep your Joomla! out of date, would you? RELIABILITY Every software has bugs – but it’s better when they’re fixed 

WHY START WITH THIS? For quite some time all of our development has been done with PHP 7+ environments. The code I’m about to show you is possible thanks to PHP 7 – just a few lines and you can resize any image without much hassle. There was a time when resizing an image was a 200kb PHP class file. Hosting servers use different environments. The following code might not run well on older versions of PHP – don’t blame the messenger 

FORM SCRIPTING AREAS PROCESS AFTER PROCESS DISPLAY When form is submitted, regardless if it passes validation or not. After form has been submitted successfully, data has been stored and emails have been sent. When form is shown. Useful for manipulating the form’s HTML layout.

THE PROCESS IN A NUTSHELL Check if form passed validation Resize the image to our desired dimensions. Validation Create image Scale image Save image We need an image resource based on the uploaded file. Overwrite the uploaded file with our resized version.

LET’S START WITH THE UPLOAD FIELD The only notable thing here is the “Name” property of the field – this is how we’ll reference it in our scripts. For this demo, I’m using Image Upload as the actual name. We’ll start by allowing some web friendly extension formats to make sure the user doesn’t upload something else – jpg, jpeg and png.

PHP GD IMAGE LIBRARY FUNCTIONS imagecreatefromstring(string $image) Loads a new image resource by using our uploaded file’s contents, without the need to identify which image format is being uploaded – PHP automatically detects the image type through this function, which saves us some hassle. imagescale(resource $image, int $new_width, int $new_height = -1) imagejpeg(resource $image, mixed $to, int $quality = 75) Saves the loaded image resource to a JPEG file – we can also specify the quality (0 – 100). The default value should be 75. Resizes the loaded image based on the new width we specify; the height is calculated automatically to maintain the original aspect ratio. Remember when I said “don’t use older versions of PHP”? This function had a bug in older versions.

RSFORM! PRO VARIABLES $invalid Based on this variable we can determine if the form is valid or not. If it’s valid, this is an empty array; if not, the array is populated with fields that failed validation. $_FILES[‘form’][‘tmp_name’][‘name-of-field-here’] Uploaded files have a funky structure in PHP – we make it even funkier by prefixing everything with a ‘form’ array. Sorry about that.

PUT IT ALL TOGETHER if (!$invalid) { $field = 'Image Upload'; $new_width = 256; $image = imagecreatefromstring(file_get_contents($_FILES['form']['tmp_name'][$field])); if (is_resource($image)) $image = imagescale($image, $new_width); $to = $_FILES['form']['tmp_name'][$field]; imagejpeg($image, $to, 75); } Script goes in Form Properties – PHP Scripts – Scripts called on form process

This is how my form looks in the frontend. THIS IS THE RESULT. This is how my form looks in the frontend. After submission, this is the Thank You message that’s displayed. I can now show the user’s picture without worrying it’s too big.

LET’S DISPLAY RESUMES IN THE FRONTEND. Let’s setup a directory. We’ll set PDF Support to Yes and the PDF Filename can use placeholders too – so we’ll have a personalized name for each PDF file. In the Fields tab we can select which fields we want to display in the frontend. Last step is to create a menu item and set Enable submissions directory to Yes so we can access it in the frontend. This is a security measure.

THE DIRECTORY IN THE FRONTEND Here’s how the directory looks like in the frontend. It’s searchable and sortable as well. Clicking on view details shows this – looks professional enough out of the box. This is the 2 Columns layout. Next, let’s open the PDF.

DISAPPOINTMENT! Wait, this doesn’t look professional at all! Because having a full fledged PDF library such as dompdf made the RSForm! Pro installation package too big to upload, we’ve included an older, barebones version of TCPDF. TCPDF was the library Joomla! 1.5 was using. It does its job as long as you don’t want it too look good  But there’s a solution for this…

MUCH BETTER. How is this possible with no lines of code? Just by installing the PDF Plugin. It features the latest version of dompdf which supports CSS styling and more complex HTML parsing. Just by installing the PDF Plugin all PDF files generated by RSForm! Pro will use the newer library, making everything look better. Much better.

Yes, I’ve said it in the same sentence – regex and simple. HOW ABOUT IMAGES IN THE LISTING? Wouldn’t it be easier to display images in the listing, so you can identify a likeable face? This is possible, but not without some code. Fortunately we have a PHP Scripts section in the directory as well and we can manipulate the HTML output using some simple regex. Yes, I’ve said it in the same sentence – regex and simple.

Let’s preg_replace() 1 2 3 4 Let’s take a look at one of the URLs <a href=“/view-resumes?task=submissions.view.file&hash=da8f6d858bb08a91ddca4833339d97f7”>name.jpg</a> So basically we have to match all links that have the submissions.view.file word in them. Use a non-greedy (lazy) search 2 The most simple syntax in regex is this: .* which matches everything. You need to use .*? – notice the question mark - which matches everything without exhausting results. Grab the link (and escape) 3 <a href=“(.*?submissions\.view\.file)”>.*?<\/a> By now we have the whole URL (the href part) and the whole <a> tag. Replace it with an <img> tag 4 <img src=“$1” /> This is actually the easiest part 

PUT IT ALL TOGETHER (AGAIN) $pattern = '/<a href=“(.*?submissions\.view\.file.*?)">.*?<\/a>/'; $replacement = '<img src="$1" />'; $directoryLayout = preg_replace($pattern, $replacement, $directoryLayout); Script goes in Directory – PHP Scripts – Scripts called on Listing Layout

“ How many developers does it take to change a lightbulb? 35. One to actually change the bulb and 34 to say after the fact, "I could have done that better." “

THANK YOU FOR WATCHING support@rsjoomla.com www.rsjoomla.com